Login.vue is where I set the sessionStorage
sessionStorage.setItem('accessToken', response.data.response.accessToken)
Logout.vue is where I want to delete the sessionStorage
sessionStorage.removeItem('accessToken')
However, after logout and redirect to Login.vue, the accessToken value is still in the sessionStorage. Am I doing it wrongly ?
Login.vue is where I set the sessionStorage
sessionStorage.setItem('accessToken', response.data.response.accessToken)
Logout.vue is where I want to delete the sessionStorage
sessionStorage.removeItem('accessToken')
However, after logout and redirect to Login.vue, the accessToken value is still in the sessionStorage. Am I doing it wrongly ?
Share Improve this question asked Aug 21, 2018 at 5:34 kylaskylas 1,4656 gold badges25 silver badges41 bronze badges 3- "the accessToken value is still in the sessionStorage" <- how are you verifying this? – Phil Commented Aug 21, 2018 at 5:39
-
1
How are you retrieving the access token in
Login.vue
? Is it possible that it's being read prior to theremoveItem()
call? – John Ellmore Commented Aug 21, 2018 at 5:40 -
Have you tried to remove the token by use it as follow:
sessionStorage.setItem('accessToken', null)
? – node_modules Commented Aug 21, 2018 at 6:37
2 Answers
Reset to default 3sessionStorage
data are only accessible from the window it was created. Trying to manipulate it from another window will not work.
Consider using localStorage
instead.
Use LocalStorage,
To Add Item
localStorage.setItem('accessToken', response.data.response.accessToken);
To Remove Item,
localStorage.removeItem('accessToken');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745209291a4616742.html
评论列表(0条)