vbrgr
vbrgr

Reputation: 839

Authentication using JWT token session storage vs local storage which authentication is secure and how

how token stores in local storage and session storage how to genrate token and which is secure for admin user authentication for angular app angular authentication using token storage is secure same as session storage in browser or application

Upvotes: 0

Views: 706

Answers (2)

hyunchel
hyunchel

Reputation: 161

In my understanding of JWT, local/session storage, and your question, using session storage to have JWT stored would be ideal as session storage is separate for each browser tab. It's just easier for a developer to manage tokens this way.

In terms of security, both local and session storage should be okay given that JWT is ephemeral.

Upvotes: 0

vbrgr
vbrgr

Reputation: 839

Local storage is a new feature of HTML5 that basically allows you (a web developer) to store any information you want in your user’s browser using JavaScript. 
In practice, local storage is just one big old JavaScript object that you can attach data to (or remove data from). 
Example:
// Considering it as a object
localStorage.userName = "highskillzz";
//or this way!
localStorage.setItem("objects", "0");

// Once data is in localStorage, it'll stay there forever until it // is removed explicitly 
console.log(localStorage.userName + " has " + localStorage.objects + " number of objects.");

// Removing data from local storage is also pretty easy. Uncomment 
// below lines
//localStorage.removeItem("userName");
//localStorage.removeItem("objects");

It was designed to be a simple string only key/value store that developers could use to build slightly more complex single page apps. That’s it.

Upvotes: 0

Related Questions