Brahim Bessrour
Brahim Bessrour

Reputation: 117

Chrome deletes the localstorage after closing the tab Vuejs

I am developing a web app with Vuejs, and i am using localstorage to store the jwt token , but after i close the tab I found that the token is lost and I need to login again . i tested the app on Opera GX and it is working just fine, i am having the issue only in Google Chrome.

This is how i set the token :

localStorage.setItem("token", token);

and this is how i load it :

let token = localStorage.getItem("token");

Upvotes: 2

Views: 1328

Answers (1)

Brahim Bessrour
Brahim Bessrour

Reputation: 117

I think the issue is from Chrome ,

you need to localstorage.getItem("X") befor you setItem("X","V")

and now the localstorage is persist , even after closing the browser .

this link helped me: Why isn't localStorage persisting in Chrome?

Upvotes: 3

Related Questions