jQuery 在浏览器/选项卡关闭时结束会话
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19582615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
End Session on browser/tab close
提问by user1890098
I have browsed through out the internet. I can't find a proper solution for this. Is there a proper way to kill/end session when browser or tab is closed without logging off?
我已经浏览了互联网。我找不到合适的解决方案。当浏览器或选项卡关闭而不注销时,是否有正确的方法来终止/结束会话?
I have tried all the codes in javascript that I found on internet. None of them work.
我已经尝试了我在互联网上找到的所有 javascript 代码。他们都没有工作。
All my users use IE only. So the code can work for that alone. Any tech is fine with me ie, javascript, jquery, ajax. Is there any solution for this? I know HTTP is stateless, browser event is client side and all that. But someone should have a working code for this. Please help.
我所有的用户都只使用 IE。所以代码可以单独工作。任何技术都适合我,即 javascript、jquery、ajax。有什么解决办法吗?我知道 HTTP 是无状态的,浏览器事件是客户端等等。但是有人应该为此提供工作代码。请帮忙。
回答by uzer
There is no working code for this. The only 100% working way, especially in case of IE – using keep-alive requests and clear session by timeout on user inactivity.
没有适用于此的工作代码。唯一的 100% 工作方式,尤其是在 IE 的情况下 - 使用保持活动请求并通过用户不活动超时清除会话。