tymondesigns / angular-locker

🗄️ A simple & configurable abstraction for local/session storage in angular js projects

Home Page:https://npm.im/angular-locker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the value in storage after I close the browser

hank-hong opened this issue · comments

The version is angular-locker "2.0.4".
I put the value in storage, for example:

var storage = locker.driver('local');
storage.put('user', user);

After I close the browser and reopen, input the url to enter in page, I found the value is still in storage.
storage.has('user') == true

Could you please tell me how to set the configuration to make the value clear after I close the browser?

Thank you.

You need to use the session driver instead. e.g.

locker.driver('session').put('user', user);

See here - https://github.com/tymondesigns/angular-locker#switching-storage-drivers

Hello @tymondesigns

Thanks for your quickly response, I got your point, but I also have tried this solution.
If I used locker.driver('session').put('user', user); the value will be lost in other tab in the same browser.
Do you know this issue?

I want to save the use info in the browser, ex: I can open many tabs in the same browser.