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 SCRIPTI 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 withsession_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.