On a browser, sessionStorage in Safari's Private Browsing does not work the same as Chrome's Incognito Mode and Firefox's Private Window?
Asked Answered
K

3

30

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?

Kobylak answered 17/9, 2013 at 21:20 Comment(3)
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.Implausibility
ts 2017 now , has anything changed in regards to private browsing mode (incognito)Mroz
@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.Cao
S
29

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.

Strafe answered 17/9, 2013 at 23:21 Comment(7)
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 helpsHussein
@BogdanMates except it doesn't persist anything which renders localStorage useless.Ind
@Esben Skov Pedersen, how exactly do you expect data to persist in private browsing mode? It would be violation of privacyPinch
@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.Ind
This answer has irrelevant information about localStorage that makes it confusing and misleadingCao
This answer no longer appears to be true with the newer versions of Safari. SessionStorage seems to work while private browsing with Safari.Cosmopolis
SessionStorage no longer works with latest version of ChromeLornalorne
N
7

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

Nole answered 11/12, 2018 at 20:56 Comment(0)
I
5

Safari Pivate mode supports localstorage and SessionStorage.

enter image description here

Icelandic answered 24/5, 2019 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.