localStorage polyfill doesn't work on Safari private browsing (window.localStorage cannot be overwritten)
Safari private browsing disables localStorage but also makes window.localStorage readonly, inconveniently. What's the best workaround for this?
I will take a look at the problem one of the next days. But for now:
As I recall, when using safe browsing, a try catch around the "setItem" and "getItem" will catch an error. In such situations one could fallback to using one of the other solutions, such as the FlashStorage.
I ran the tests in incognito mode in the newest versions of Firefox, Chrome and Opera and no problems seems to occur there. I'll try to get access to a Windows machine to tests the Safari private browsing.
Yeah AFAIK this is a specifically Safari problem. I have notes on it somewhere but the jist of it is that each of the browsers handles private sessions differently and that Safari's (decidedly un-private) method is to make localStorage available but readonly.
A Googling turned this up: https://blog.whatwg.org/this-week-in-html-5-episode-30
Sorry to revamp an old issue, but what @christopherliu is saying is that you cannot overwrite localStorage when Safari is in private mode.
https://github.com/mortzdk/localStorage/blob/master/dist/localStorage.js#L694
Any plans on working around this?
I will take a look at the problem, but I must postpone the matter till after the 21. of June, since I'm in the process of writing my Master's Thesis.
Was passing exactly through this problem and found a module that deals using this technique: https://raw.githubusercontent.com/ripeworks/local-storage-fallback/master/src/hasStorage.js
The same technique I use in version 3.0, which is on its way :)
Hi @mortzdk , thanks for the good work, Just wondering if version 3.0 is out and/or safari issue in private browsing has been fixed?. Thank you again
Hi @eduzol, sorry for not making the v3.0 branch public. It is now public as v3.0 i.e. it is not released yet.
Feel free to do some testing :)
@mortzdk Whats the release schedule?
How does localStorage persist information in Incognito mode?