cookies - How to save in local storage of Safari Private Mode -


i have app saves user name in local storage. works fine every browser except safari in private mode.

is there way save variable in safari private mode? tried using cookies it's doesn't work...

any work around?

i implemented localstoragehandler checks if browser supports local storage, if doesn't support use cookie.

this function checks if supports local storage:

localstoresupport: function () {     var testkey = 'test', storage = window.sessionstorage;     try     {         storage.setitem(testkey, '1');         storage.removeitem(testkey);         return true;     }     catch (error)     {         return false;     } } 

and how dealt false:

if (this.localstoresupport())     {         localstorage.setitem(name, value);     }     else     {         document.cookie = name + "=" + encodeuricomponent(value) + expires + "; path=/";     } 

i hope helps you.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -