强制清理会话Cookie(Firefox,Chrome)

Ond*_*dar 5 cookies session firefox

Some browsers (Firefox, Chrome) by design doesn't clean session cookies when you close them, if you set some kind of remember me switch (for example in FF go to Options->General->When Firefox starts->Show my windows and tabs from last time). It is a problem for our client (government agency...) while I do have absolute control over http server, I have no control over browser settings. The scenario is - they're used to share computer accounts, however they shouldn't be able to share web accounts - simply closing the browser should kill the session never mind the browser settings.

Is there an elegant way how to enforce that ?

目前,我想到的唯一解决方案是某种死人的开关(将cookie更改为仅生存一分钟(服务器端加密时间戳),并且在每个页面上都有javascript“ pinger”,每半分钟ping 20分钟服务器上的一些“延长会话”处理程序(登录会话应为20分钟,滑动到期)。

Cli*_*des 0

您可以尝试使用 HTML5s sessionStorage 它持续页面会话的持续时间。只要浏览器打开,页面会话就会持续,并且在页面重新加载和恢复后仍然存在。在新选项卡或窗口中打开页面将导致启动新会话。

sessionStorage.setItem("用户名", "约翰");

https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#sessionStorage

浏览器兼容性 https://code.google.com/p/sessionstorage/ 与所有 A 级浏览器兼容,包括 iPhone 或 Android。 http://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/