使用后退按钮的会话问题

时间:2014-07-28 18:13:42

标签: php session caching browser-cache

我在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.

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

1 个答案:

答案 0 :(得分:3)

我将它设置在我的php页面顶部

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

并解决了问题