4

I've done quite a bit of googling, and I can't find any straight answers on how reliable localstorage is supposed to be. After storing some data from an HTML5 page, leaving the iPad idle for about an hour, and then closing Safari (swipe up) and then opening it again - the data was gone!

It is my understanding that this was a known issue in iOS 5 and 6, but in iOS 7.0.3, the issue was supposedly resolved - and yet, I'm seeing disappearing data in iOS 7.1.2. And I have no idea whether this is due to leaving the iPad idle for an hour (it was my understanding that local storage was persistent - forever - until you cleared it), or due to the hard reset of Safari (again, closing the browser shouldn't wipe your data, should it? I've found confirmation that data is supposed to persist across tabs and windows.)

I've seen some warnings not to count on localStorage - but I'd like to know why not - under what circumstances can I expect it to work, or is it pretty much still a diceroll even on the latest version of iOS/mobile Safari? Would I have better luck with Chrome, or is this a device issue, not a browser issue?

Any insight on this would be much appreciated.

Nicole Stein
  • 925
  • 1
  • 9
  • 23
  • Nicole, I posted an update to my question that may be of interest to you. http://stackoverflow.com/questions/25627991/ios-7-webview-and-localstorage-persistence-update . My experiences, with an app webview, is that it persists across app restart and device reboot. But, my iPad is brand new and thus lots of free space - I read somewhere iOS will del cache files when dick space goes low – KevInSol Sep 08 '14 at 10:12
  • Thanks! I'm wondering whether there may be a difference between our two issues, though, in that you're using Cordova and I'm just opening a web page in Safari - sounds like the data is stored in different places. Not sure if that means local storage with Cordova is more reliable than regular local storage? – Nicole Stein Sep 08 '14 at 14:04
  • Note that in most browsers the call to `localStorage.setItem` will throw a script error when there's not enough space. I recommend wrapping it with a `try catch`, or use cookies. – oriadam Apr 11 '16 at 13:30

0 Answers0