Reputation: 617
I'm currently working on an Angular application and when the user is authenticated I'd like to store some data in locale storage. I'm wondering if I store the user level access in it? Is that a best practice?
Upvotes: 0
Views: 1751
Reputation: 6814
You can certainly store user authentication token in local storage, but it is best just to keep it around during the session, so use session storage is a better choice which has the same APIs, they only differ in semantics
local storage -> persists beyond the current session
session storage -> is destroyed when the browser is closed.
Local storage and session storage are subject to the same CORS policy as other static resources, so you are safe to store user authentication data in there
Upvotes: 1