Home > database >  Chrome deletes the localstorage after closing the tab Vuejs
Chrome deletes the localstorage after closing the tab Vuejs

Time:11-27

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");

CodePudding user response:

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?

  • Related