Safari 后退按钮不支持 PHP 注销会话

发布于 2024-09-04 12:02:33 字数 588 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小糖芽 2024-09-11 12:02:33

确保您提供的任何需要身份验证的页面都使用合适的缓存控制标头发送。该页面是从浏览器缓存中显示的,通过提供明确禁止缓存的缓存控制,您应该能够阻止这种情况。

来自 http://php.net/manual/en/function.header.php

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

特别是对于 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

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文