简体   繁体   English

注销后本地存储数据仍然存在

[英]Local storage data persisted after logout

I'm building a React web app. 我正在构建一个React Web应用程序。 It stores a token in localstorage after user login through a 3rd party Oauth2 service. 用户通过第三方Oauth2服务登录后,它将令牌存储在本地存储中。

When an user logout, localstorage.clear() did cleared the token. 用户注销时,localstorage.clear()确实清除了令牌。

Storage {length: 0}

However, if I click the brower's back button a couple of times, I'm back in the app, the token re-appear in local storage like I've never logout before. 但是,如果我几次单击浏览器的后退按钮,则我又回到了应用程序中,该令牌重新出现在本地存储中,就像我以前从未注销过一样。

I've tried: 我试过了:

localstorage.clear(), localStorage.removeItem('accessToken'), location.reload(true) ...

How can I clear out the storage and history? 如何清除存储和历史记录?

There's no way of getting back the localstorage value once you clear/removeItem . 一旦clear/removeItem ,就无法取回localstorage值。 I'm guessing you're using redux and storing your token somewhere in the store. 我猜您正在使用redux并将令牌存储在商店中的某个位置。 When you click back, at some point you are probably saving it to the localstorage again. 单击后,有时可能会将其再次保存到本地存储中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM