为什么不关闭标签页删除会话Cookie? [英] Why Doesn't Closing A Tab Delete A Session Cookie?

查看:528
本文介绍了为什么不关闭标签页删除会话Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用基于会话的Cookie与我的网站。令我完全惊讶的是,我注意到如果我设置了一个会话cookie(不是持久性cookie),关闭一个选项卡,然后重新连接到网站,会话cookie仍然存在。这不是我想象的,实际上。我希望会话cookie被删除。

I'm using session-based cookies with my website. To my complete surprise, I noticed if I set a session cookie (not a persistent cookie), close a tab, and then reconnect to the site, the session cookies are still there. That's not what I would have expected, actually. I would have expected the session cookies to be deleted.

如果您关闭浏览器,会话Cookie会被删除,为什么不关闭标签以获得相同的结果?

If you close the browser, a session cookie is deleted, so why not closing a tab to have the same result?

因此,我使用PHP5和jQuery。有什么我可以做的,当一个标签页关闭我可以解决这个会话问题?不幸的是,BODY标签上的onbeforeunload事件在这里没有用处,因为当您点击远离某个网页时,它会触发该事件,而不只是关闭标签页。

Therefore, I'm using PHP5 and jQuery. Is there anything I can do such that when a tab is closed I can fix this session issue? Unfortunately the onbeforeunload event on the BODY tag is not useful here because when you click away from a page it fires that event, not just closing a tab.

推荐答案

会话cookie是每个进程不是每个窗口。因此,即使您选择了New Window,仍然会得到相同的会话ID。这种行为是有道理的。您不希望用户每次在浏览您的网站时打开新窗口时重新登录。

The session cookie is per-process not per window. So even if you selected New Window you'd still get the same session id. This behavior makes sense. You wouldn't want a user to re-sign in each time they opened a new window while browsing your site.

我不知道任何真正的方式围绕这个。

I'm not aware off hand of any real way around this.

这篇关于为什么不关闭标签页删除会话Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆