Closed ashiefk closed 9 years ago
you can't share data between multiple tabs using sessionStorage, because a new page is a new session
see MDN
Opening a page in a new tab or window will cause a new session to be initiated, which differs from how session cookies work.
You need to replace
. setStorageType('sessionStorage')
by
. setStorageType('localStorage')
// which is default
Thank you so much, really helpful info.
Is there a way to get the best of both worlds? When the browser is closed the session no longer exists (as is the case with "sessionStorage") but while actively using the browser the user will stay logged in across tabs?
Correct me if I'm wrong, but I think this is the type of behavior you would see using something like PHP to manage the sessions.
I have implemented localstorage in my web app configuration given below,
app.config(function (localStorageServiceProvider) { localStorageServiceProvider .setPrefix('appName') .setStorageType('sessionStorage') .setNotify(true, true) });
and i set some data inside localstorage but when i checked in different tab (browser tabs) its returning null. Is there anything which i missed in configuration (do i need to change sessionStorage to cookie?). Is there anything i need to specify inorder to share the data between tabs? Please help !!! I really need the data between tabs just like server session.