tymondesigns / angular-locker

🗄️ A simple & configurable abstraction for local/session storage in angular js projects
https://npm.im/angular-locker
MIT License
314 stars 42 forks source link

Why the value in storage after I close the browser #35

Closed hank-hong closed 7 years ago

hank-hong commented 7 years ago

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.

tymondesigns commented 7 years ago

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

hank-hong commented 7 years ago

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.