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.
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.
Share Improve this question edited May 7, 2012 at 18:45 ewein asked May 7, 2012 at 18:28 eweinewein 2,7356 gold badges40 silver badges57 bronze badges 3- 2 Do you have some example code to show exactly what you are storing? – Brant Olsen Commented May 7, 2012 at 18:37
- What versions of IE do you need to support? – i_am_jorf Commented May 8, 2012 at 15:55
- I need to support IE 8 and IE 9. – ewein Commented May 8, 2012 at 17:32
3 Answers
Reset to default 2If 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).
For IE, you can use a polyfill to simulate a native localStorage: https://github./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.
localStorage in IE does not work with this url: file:///P:/Dropbox/abc_web/ingrid8/ingrid.htm#car..
through network if it works: file://pedrojelp/p/Dropbox/abc_web/ingrid8/ingrid.htm#car..