Safari/Opera 会话 cookie 过早删除
我已经设置了一个生命周期为 0 的 PHP 会话 cookie(在浏览器关闭时过期),但仅几秒钟后我就从会话中注销了。
我正在观察 safari cookie 弹出窗口(在 safari 首选项中),在重新加载页面时,我看到 cookie 从列表中消失,只是在重定向到登录页面(其中启动新会话并从而设置cookie)。
这与歌剧的行为方式相同。
不过火狐浏览器还不错。事实上,我已经使用这个网站有一段时间了,在 Firefox 中没有遇到任何问题,所以如果它也影响它,我现在应该已经看到了。
我尝试过使用大量 HTTP 标头(例如 Cache-control)进行工具处理,检查 session_write_close()
是否位于正确的位置(但这实际上并不重要,因为我只是刷新页面),我也检查了会话垃圾清理设置,但是当我看到这些 cookie 自行消失时,我差点从袜子里跳出来!
苹果电脑10.6.4 歌剧 10.10 safari 5.0.2
我还应该提到这个网站正在进行 ajax 请求,尽管它们都没有尝试以任何方式(直接)破坏会话或删除 cookie。
编辑:刚刚在 win XP 上测试:FF 好吧,Safari 与 Mac 上的现象相同。
编辑:这段简短的视频说明了 Windows 上的此问题。
I've set a PHP session cookie with lifetime 0 (to expire on browser close) but I've been getting logged out of the session after only a few seconds.
I am observing the safari cookies popup window (in safari preferences) and while reloading the page I see the cookie vanish from the list only to be replaced by a new session id when being redirected to the login page (where a new session is started and thus cookie set).
This behaves the same way with opera.
Firefox is fine however. In fact I've been using the site for a while without any trouble in firefox so if it were to affect it too I would have seen it by now.
I have tried tooling with numerous HTTP headers like Cache-control, checked that session_write_close()
is in the right spots (but really this shouldn't matter because I'm just refreshing the page), also I checked the session garbage clean up settings, but when I saw these cookies vanish on their own I almost jumped out of my socks!
mac 10.6.4
opera 10.10
safari 5.0.2
I should also mention this site has ajax requests going on, though none of them attempt to destroy the session or remove the cookie in any way (directly).
EDIT: Just tested on win XP: FF okay, Safari same phenonmenon as on Mac.
EDIT: This short video illustrates this issue on Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个帖子:
https://discussions.apple.com/thread/4032092
我的最好的答案是,不要设置过期时间,而是设置一个明确的未来日期/时间。
Take a look at this thread:
https://discussions.apple.com/thread/4032092
My best answer is, instead of setting no expiration, set an explicit date/time in the future.