#native_company# #native_desc#
#native_cta#

Manually Expiring Web Pages

By Joe Clark
on July 2, 2003

After going through a series of pages during a registration
process, you don’t want the user to be able to go back after the
final submit. What can you do to manually “expire” those pages, and
perhaps display a custom message?
In this scenario, I didn’t want my session to expire as I needed
it to continue. Instead, I used an extra session variable to track
whether my session was alive or not. There are four main
components:
(1) the entry script,

(2) the Cache-control directive,

(3) the conditional check, and

(4) manually expiring a portion of the session.

THE ENTRY SCRIPT

I use an entry script to start my session. This accomplishes two
things: (1) destroys any session already in progress, and (2)
starts a new session.
entry.php:

<?php

session_start
();

session_unset();

session_destroy();

session_start();

session_register('alive');

$_SESSION["alive"] = "1";

Header("Location:/php/createaccount.php");

?>



In the above script, we start the session, get rid of any
registered session variables with session_unset(), and destroy that
session with session_destroy(). Then, we start a new session and
register a session variable. This particular variable will track
whether this portion of the session is alive or not. We set the
variable to some value, then we redirect to our first page in the
registration series.