DEV Community

Akhil Ashok
Akhil Ashok

Posted on Edited on

How to store jwt token in cookies of browser when user loggedIn?

How to store jwt token in cookies of browser when user user logged in (technologies used angular 8 + spring security)

Top comments (5)

Collapse
 
saschadev profile image
Der Sascha •

I do not know if it is a good practise, but I think it will be better to get a New token. That ensures you that your token is always Active. Otherwise you must check by yourself if the token was expired and so on

Collapse
 
pyyding profile image
Kaspar Püüding •

It is so straightforward. Use a library like github.com/7leads/ngx-cookie-service and specify your question if something is unclear. :)

Collapse
 
brookesb91 profile image
Brookes •

You should use something like JWT for client authorisation. You would have a strategy in place that stores the token in local storage and is retrieved and sent in the header of each request.

Collapse
 
pyyding profile image
Kaspar Püüding •

Storing a token in local storage is a security risk. rdegges.com/2018/please-stop-using...

Collapse
 
crimsonmed profile image
Médéric Burlet •

Take a look at that its very complete:
blog.angular-university.io/angular...