localStorage and sessionStorage in Safari's private mode
09. August 2017
Posted in JavaScript
· 1 minute read If you didn't know, in Safari's private mode both localStorage
and sessionStorage
are not working. To be exact, Safari sets storage's limit to 0, so you can't write anything to it. I keep forgetting this, until QA people report it at some point.
So I quickly wrote a small facade for it, which fails silently in this case. That means it still doesn't work but it won't throw an error and break your application.
This is the version for localStorage
, just replace it with sessionStorage
if you need it.
;
;
// Try to
try catch e
;
;