29

It seems that for sessionStorage, it works differently on Chrome's Incognito Mode vs Safari's Private Browsing and Firefox's Private Window? I can find something on http://www.webdirections.org/blog/webstorage-persistent-client-side-data-storage/ but it doesn't say that Safari's Private Browsing will throw an exception.

The following is how I opened "Private Browsing":

  1. On Safari on Mac, click "Safari -> Private Browsing" on the menu bar
  2. On Chrome, use "File -> New Incognito Window"
  3. On Firefox, use "File -> New Private Window"

and on Safari, sessionStorage does not work, and if I do the following in the console:

> sessionStorage["foo"] = 123.4
Error: QUOTA_EXCEEDED_ERR: DOM Exception 22

> sessionStorage["foo"] 
undefined

but on Chrome or Firefox, sessionStorage works as usual (as non-private browsing). Is the above accurate as far as sessionStorage is concerned?

3
  • 1
    On a related note, you might want to file a bug / feature request to Apple about this particular behavior if you wished it to behave like the other browsers. But first check openradar.appspot.com/page/1 if it's already filed, and if not, then file bug to Apple and file a copy to OpenRadar for public tracking. Don't like how Apple does not make their bug tracker publicly viewable by all.
    – David
    Nov 23, 2016 at 17:28
  • ts 2017 now , has anything changed in regards to private browsing mode (incognito)
    – Nigel Fds
    Jun 19, 2017 at 5:06
  • 3
    @NigelFds It looks like it has. as of version 11.0.2 Safari's Private Browsing now acts the same as Chrome's Incog and Firefox' Private Browsing - Storage is usable. Saying if it persists between tabs or not is irrelevant as sessionStorage is for that tab only.
    – George
    Feb 22, 2018 at 10:03

3 Answers 3

28

Your assessment is practically accurate:

  • Safari will just use a quota of 0 in private mode, so all attempts to set a value will fail. This is kinda OK according to the spec, as the spec does not mandate a minimum space requirement.
  • Chrome and Firefox still allow you to use storage, however private storage is independent from non-private, i.e. setting an item in private mode will not reflect back into non-private mode (important for localStorage only).

Please note that other browsers are also free to throw QuotaExceededError exceptions at any given time, should you go over the quota.

7
  • 2
    I had the same issue and solved it by loading the following script on my layout: <gist.github.com/engelfrost/fd707819658f72b42f55 >? It checks if localStorage can be used and if not, it creates an alternative which works the same way. Hope this helps Jul 28, 2016 at 12:57
  • @BogdanMates except it doesn't persist anything which renders localStorage useless. Feb 15, 2017 at 6:03
  • @Esben Skov Pedersen, how exactly do you expect data to persist in private browsing mode? It would be violation of privacy May 14, 2017 at 14:30
  • @KirillSlatin It could have the same semantics as cookies in chrome incognito. Starting with a clean slate and deleted after session is closed. Session storage could work exactly the same way as non-private mode with no violation of privacy. May 14, 2017 at 14:46
  • 2
    This answer no longer appears to be true with the newer versions of Safari. SessionStorage seems to work while private browsing with Safari.
    – Anton
    May 29, 2020 at 15:08
6

Safari latest version (Version 12.0) already have access to sessionStorage without any issue in incognito mode. enter image description here

5

Safari Pivate mode supports localstorage and SessionStorage.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.