25

I have a web application written in JavaScript that runs successfully on the desktop via Safari as well as on the iPhone.

We are looking at porting this application to the iPad and we are running into a problem where we are seeing QUOTA_EXCEEDED_ERR when storing a relatively small amount of data within the localStorage on the device. I know what this error means, but I just don't think I'm storing all that much data.

Is anyone else doing something similar? And seeing/not seeing this problem?

Kevin...

Kevin
  • 9,309
  • 12
  • 44
  • 51
  • After further investigation, I really can't see why I would be getting this error, the storage I'm using is probably < 1-2K. I ended up just replicating the functionality in the database, however this required doing everything asynchronously. – Kevin Apr 09 '10 at 16:34

5 Answers5

31

I had the same problem and it seems like removing the key before setting it solved it.

function setkey(key, val){
  sessionStorage.removeItem(key);
  sessionStorage.setItem(key, val);
}
Dan Breen
  • 12,626
  • 4
  • 38
  • 49
kioopi
  • 2,170
  • 2
  • 18
  • 26
7

it's not a bug, the user can go to the settings of there iphone and then choose safari. there is a option to set private brouwsing. default is on so storage works but some disable it. so you should create a message in your app telling theme to enable it.

mike
  • 71
  • 1
  • 1
  • Thanks, that worked for me. It makes sense, if private browsing is on then nothing should be stored. – Leo Moore Nov 24 '12 at 13:21
  • 1
    It's the other way for me: private browsing off, localStorage works; private browsing on, localStorage doesn't work. Version 5.1.1 – Mr. TA Jun 19 '13 at 15:27
  • @Mr.TA I ran into the same problem. http://caniuse.com/#feat=namevalue-storage mentions this issue in the "Notes" section. – David Ipsen Jun 28 '13 at 19:12
3

If you use the way removing storage data before set it - it would be very slow in some browsers. Removing data is 1.5 times slower than set it (strings about 50 signs). Tried on FF 3.6 (Ubuntu) - browser works very slow with SqlLite. So, do this hack only for iPad devices.

SAHbKA
  • 327
  • 1
  • 2
  • 14
2

Hey I'm getting the same issue. I tried my app on an iPad and it was spitting out this error. The only way I could replicate it on my Safari browser is if I put my computer in Private mode...

I think anytime it's in private mode the localStorage becomes read only. So I still don't have a solution, but if it helps I'd love to hear it.

Dairo
  • 822
  • 1
  • 9
  • 22
David
  • 21
  • 1
  • What I found is that I can indeed store some data within localStorage, but just all that much. So I'm not sure it's a readonly issue. – Kevin Apr 10 '10 at 14:47
  • My issue was the private mode on. Turn it off and localStorage becomes usable again. Version 5.1.1 – Mr. TA Jun 19 '13 at 15:25
2

I had the same issue on my iPad running os version 3.something (sorry can remember the exact version). I upgraded the os to 4.2.1 and the problem is solved!

Seems to have been a bug in Apple's implementation of localstorage which has since been fixed.

Zach Mathew
  • 451
  • 5
  • 5