user3504335
user3504335

Reputation: 177

Session Issue with Back Button

I have this code in a php file and its include in all the page which I want to share and protect my page.

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'];

Problem is lets say I have a page which have

Register > Select Service > Select Payment Mode

Assume at Payment Mode, user realize he key something wrong at page 2, select service, he press the back button, an error occur, which due to the usage of session.

The error is

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.

What should I do with such incident, I want to use session to protect my page, but I also want user to have the capability to back to the previous page without hurting session.

Upvotes: 4

Views: 733

Answers (1)

user3504335
user3504335

Reputation: 177

I set this at the top of my php page

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

and its fixed the issue

Upvotes: 3

Related Questions