小编Set*_*eth的帖子

PHP - Session_Destroy 按下后退按钮

这是我的问题:

我有一个名为 login.php 的登录页面(不包含 HTML 代码)。当用户正确输入他的凭据时,他会被重定向到特定页面;对于这个例子,我们会说 test.php。该页面上的唯一链接注销当前会话,并将用户返回到 index.html。

我的问题是,如果用户按下后退按钮,它会返回到 login.php 并且您会得到一个空白页面。如果您离开那个空白页面,您将无法返回 test.php,因此无法注销该会话。

我最初的想法是使用 Javascript 禁用后退按钮导航。最终我发现这是行不通的,因为如果用户找到一种方法可以在不注销的情况下退出该页面,他们将被困在该会话中并且 login.php 将是空白的。

那么如果按下后退按钮,有没有办法结束当前会话?或者如果 login.php 重新加载?我对 PHP 不太熟悉,因此非常感谢详细的解释。

这是登录页面的代码:

    <?php
    /**
     * The idea of this application is to secure any page with one link. I know some of the professionals
     * will agree with me considering the way it has been done, usually you wouldnt put any other information such as
     * HTML/CSS with a class file but in this case its unavoidable. This is …
Run Code Online (Sandbox Code Playgroud)

php session refresh back destroy

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

back ×1

destroy ×1

php ×1

refresh ×1

session ×1