Safari 后退按钮不支持 PHP 注销会话
我有一个 logout.php 页面,它结束用户的会话并且运行良好,并执行以下操作:
session_start(); session_unset(); session_destroy();
我刚刚在使用 Safari 进行测试时注意到,当您注销时,您可以单击后退按钮返回到需要身份验证但不会提示的上一页。您无法在不进入导航的情况下离开此页面,但它不应该首先显示上一页。
到目前为止,在我的测试中,这只是 Mac OS X 上 Safari 的问题,还有许多其他关于此问题的报告,但我找不到解决方案:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23702691.html
我会我很高兴能够通过 Safari 的后退按钮禁用此行为 - 令人惊讶的是,这种情况首先发生。
谢谢, 史蒂夫
I've got a logout.php page which ends a user's session and works well and does the following:
session_start();
session_unset();
session_destroy();
I've just noticed when testing with Safari that when you logout you can click the back button to return to the previous page which requires authentication but are not prompted. You cannot navigate away from this page without entering the navigation but it should not be displaying the previous page in the first place.
So far in my testing this is only an issue with Safari on Mac OS X and there are a number of other reports about this but with no resolution that I could find:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23702691.html
I would love to be able to disable this behaviour with Safari's back button - surprised that this is happening in the first place.
Thanks,
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您提供的任何需要身份验证的页面都使用合适的缓存控制标头发送。该页面是从浏览器缓存中显示的,通过提供明确禁止缓存的缓存控制,您应该能够阻止这种情况。
来自 http://php.net/manual/en/function.header.php
特别是对于 Safari,有一些关于缓存和卸载事件的讨论,您可以使用它们来避免缓存。一般来说,WebKit 似乎在缓存方面确实存在一些复杂性。
http://webkit.org/blog/427/webkit -page-cache-i-the-basics/
http://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/
Ensure that any page you serve which requires authentication is being sent with suitable cache control headers. The page is being displayed from the browser cache, by providing cache control which explicitly forbids caching you should be able to stop this.
From http://php.net/manual/en/function.header.php
Specifically for Safari, there's some discussion about caches and unload events, which you might be able to use to avoid caching. It seems that WebKit does have some complications with caching in general.
http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
http://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/