What are the alternatives to html5 session storage?(not local storage)
NickName:Akshay Shinde Ask DateTime:2015-06-11T13:18:15

What are the alternatives to html5 session storage?(not local storage)

I want 2 javascript methods to access certain data without passing this data to any of the methods as arguments. Basically I want one method to set the data and other to consume that data using the objects already available in the browser and I want the solution to work with Safari, Firefox, Chrome and IE8+ also iOS and android browsers. I believe session storage does not work on iOS. Is it correct? What are the drawbacks of session storage. I tried to append the data to the event object but it does not work in firefox and IE.

Copyright Notice:Content Author:「Akshay Shinde」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30772134/what-are-the-alternatives-to-html5-session-storagenot-local-storage

Answers
Samuli Hakoniemi 2015-06-11T07:17:53

Although sessionStorage is available for iOS, you can do following for legacy support. You can use window.name. It lives through the session (i.e. until the browser tab gets closed):\n\nvar myData = {\n 'foo': 'bar',\n 'foz': 'baz'\n};\n\nwindow.name = JSON.stringify(myData);\n\n\nAnd you can read it back:\n\nvar myData = JSON.parse(window.name);\n\n\nThis of course requires JSON support from the browser, which leaves very old browsers out of the scope.",


Matt L 2015-06-11T05:39:20

You could use a \"global variable\" (I put that in quotes because I'm not sure what it's actually called in Javascript). But basically you could just make an object in one of your javascript files and write to/read from it.\n\nSomething like\n\nvar data = { first: \"first\", second: \"second\" }\n\n\nand just make as many variables in that object as you need. And a function would access it like\n\nfunction(param) {\n var firstData = data.first;\n}\n\n\nOr I guess using cookies is closer to what you described as your own solution, but that seems like overkill if you just need to pass data between Javascript methods.",


More about “What are the alternatives to html5 session storage?(not local storage)” related questions

Local Storage, Session storage, Web storage, web database and cookies in HTML5

What is the difference between these concepts, and when should I use one in particular? Does this listing also contain different names for the same general concept? HTML5 local storage HTML5 sess...

Show Detail

Is it possible to override Local Storage and Session Storage separately in HTML5?

I know it's possible to override the HTML5 storage APIs by overriding Storage.prototype.getItem, setItem, removeItem and clear. But that will override those methods for both local storage and session

Show Detail

What are the alternatives to html5 session storage?(not local storage)

I want 2 javascript methods to access certain data without passing this data to any of the methods as arguments. Basically I want one method to set the data and other to consume that data using the

Show Detail

HTML5 session storage or local storage only returning values on home page and values not get persist on the other page

I am trying to handle session object across page using HTML5 local storage and both Local Storage and Session Storage values are not persist on the other than home page. What will be the issue?

Show Detail

Is HTML5 Session Storage secure?

Is HTML5 Session Storage secure? What I mean by this is: Can the contents be edited? Can the contents be viewed? Can the contents be deleted? Does session storage work with all major browsers? Is

Show Detail

HTML5 persistant storage: Local Storage or SQLite?

I am in the R&D phase for an application that should run on android and iOs. So I was evaluating the use of HTML5. However, I need to store some data persistently. I have found a number of art...

Show Detail

How to enable HTML5 local storage in javafx WebView

Is there a way to enable HTML5 local storage on a javafx 2.2 WebView? Whatever I do it seems that local storage is disabled/not available for the WebView supplied by javafx. I even tested it using ...

Show Detail

HTML5 Session storage vs PHP Session (Cache/DB)

I am currently updating a Web App, that I developed a couple months ago. My plan includes to integrate some HTML5 features. I'm already using the File API for the file uploads with a back fall to a...

Show Detail

Phonegap, Internet Explorere, and Local Storage or Session Storage

In this link session storage not working in IE it was stated that local storage and session storage will only work with Internet Explorer if the code is accessed as HTTP through a server, but not w...

Show Detail

lot of records in html5 local storage?

1) is it possible to store lot of records in html5 storage? 2) what is the maximum size of local storage of HTML5? 3) can we access local storage using RDBMS Concept?

Show Detail