加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 后退按钮的会话问题

发布时间:2021-08-28 03:45:44 所属栏目:大数据 来源: https://www.jb51.cc
导读:我在PHP文件中有这个代码,它包含在我要共享的所有页面中并保护我的页面. session_name("login");session_start();if (!isset($_SESSION['UserId'])) { if(!header("Location: https://subdomain.mywebsite.com/")) { die("Unauthorized access"); }}session_

我在PHP文件中有这个代码,它包含在我要共享的所有页面中并保护我的页面.

session_name("login");
session_start();

if (!isset($_SESSION['UserId'])) {
    if(!header("Location: https://subdomain.mywebsite.com/"))
    { die("Unauthorized access"); }
}

session_regenerate_id(); 
$UserId = $_SESSION['UserId'];

问题是我说有一个页面

Register > Select Service > Select Payment Mode

假设在付款模式下,用户意识到他在第2页输入错误,选择服务,他按下后退按钮,由于会话的使用而发生错误.

错误是

Document Expired

This document is no longer available.

The requested document is not available in Firefox's cache.

    As a security precaution, Firefox does not automatically re-request sensitive documents.
    Click Try Again to re-request the document from the website.

我应该如何处理此类事件,我想使用会话来保护我的页面,但我也希望用户能够在不损害会话的情况下返回上一页.

解决方法:

我把它设置在我的PHP页面的顶部

ini_set("session.cache_limiter", "must-revalidate");

并解决了这个问题

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读