[英]Logout on browser close
Is there any way to logout on browser close while using jwt token in local storage for authentication in MeanStack application. 有什么方法可以在本地存储中使用jwt令牌注销浏览器关闭,以便在MeanStack应用程序中进行身份验证。
I have used beforeunload but it is called on refresh and few other events as well. 我已经使用过beforeunload,但是在刷新时也会调用它,而其他事件也很少。
You could use sessionStorage
instead of localStorage
. 您可以使用
sessionStorage
而不是localStorage
。 The only difference is that sessionStorage
is only meant to survive the current browser session. 唯一的区别是
sessionStorage
只能在当前的浏览器会话中存活。 Another option would be to store your application state in memory (in a variable) and it will be gone on close. 另一个选择是将您的应用程序状态存储在内存中(在变量中),它将在关闭时关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.