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?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • 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 https://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 '16 at 17:28
  • ts 2017 now , has anything changed in regards to private browsing mode (incognito) – Nigel Fds Jun 19 '17 at 05: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 '18 at 10:03

3 Answers3

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.

nmaier
  • 32,336
  • 5
  • 63
  • 78
  • 2
    I had the same issue and solved it by loading the following script on my layout: ? It checks if localStorage can be used and if not, it creates an alternative which works the same way. Hope this helps – Bogdan Mates Jul 28 '16 at 12:57
  • @BogdanMates except it doesn't persist anything which renders localStorage useless. – Esben Skov Pedersen Feb 15 '17 at 06:03
  • @Esben Skov Pedersen, how exactly do you expect data to persist in private browsing mode? It would be violation of privacy – Kirill Slatin May 14 '17 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. – Esben Skov Pedersen May 14 '17 at 14:46
  • This answer has irrelevant information about localStorage that makes it confusing and misleading – George Feb 22 '18 at 10:05
  • 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 '20 at 15:08
  • SessionStorage no longer works with latest version of Chrome – MDMoore313 Sep 15 '20 at 21:53
6

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

ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
5

Safari Pivate mode supports localstorage and SessionStorage.

enter image description here

Kumar Nitesh
  • 1,634
  • 15
  • 18