DEV Community

chijuuuu
chijuuuu

Posted on

Use headers Authorization in order NOT to re-login after closing browser

Hi guys, how can I remain logged-in status after closing tab or browser. I have set Authorization for headers request. But I don't know what to do next?
In my Login component screen: I have a function to set token to localStorage
Image description

on browser:
Image description

What should I do now ?

Top comments (2)

Collapse
 
lizardkinglk profile image
sndp

Increase your token's expiration time. Save it in local storage. Use that in the next time user logs in and use it for requests. It shouldn't has been expired. And if it was redirect the user to welcome page.

Collapse
 
quocbao64 profile image
quocbao64

Save the token to local storage. After accessing the website, you will need to check whether the token has expired or not. If it has expired, please redirect the user to the login page.