Internet Explorer Local Storage

15,688

Solution 1

If you need local storage, then you need local storage! Based on the information you describe, I think it's probably too heavy to use in a session cookie.

Check out the docs. Be aware that only IE8+ supports this, so if you need to support other versions - you'll need to do some extra work.

I would personally enable localStorage where possible, then fall back to a round-trip to the server if the browser doesn't support it (and the data is definitely too much for cookies).

Update RE Polyfills

Keep in mind that the polyfills suggested by Rafael will fall back to cookies if the browser doesn't support localStorage etc. Be sure to test with a good spread of data, and keep in mind that it will be sending all that data with each request (which has it's own ramifications).

Solution 2

For IE, you can use a polyfill to simulate a native localStorage: https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

LocalStorage uses a key:value system. But you can save more than one data in one key, using JSON.Stringify & JSON.parse.

Share:
15,688
ewein
Author by

ewein

Updated on June 06, 2022

Comments

  • ewein
    ewein almost 2 years

    I have a application which works great on all browsers but IE. I am using the local database provided with HTML5. I need to store 3 attributes for the users of the application. I know in IE I can't use the database approach and I was thinking of using 3 arrays stored in local storage, one array for each attribute. Is there a better (and easier) way of doing this?

    Thanks

    For example, I want to store 1) destination 2) where they are from 3) date So I was thinking I will store an array for destinations, an array fro from locations and an array for dates. Then using some id I can index the arrays and get the corresponding information.