I'm trying to set up a timeout test on a selection of files. The files run the test via an include, which contains the following:
$inactive = 20;
/* check to see if $_SESSION['timeout'] is set */
if(isset($_SESSION['timeout']) )
{
$session_life = time() - $_SESSION['timeout'];
if($session_life > $inactive)
{
session_destroy();
header('Location: logout.html');
}
}
$_SESSION['timeout'] = time();
Each of the pages using it begin as follows:
session_start();
include ("data_fr443zzw/timeout.dat.php"); /* Timout test */
6 of the pages work as I'd expect, redirecting on timeout, but one does not. The only difference I can see is that the 6 pages are presentational and have HTML and forms as well as PHP in them. The failing page is pure PHP, dealing with POST and SESSION variables to redirect the browser to the appropriate page.
The failing page effectively continues past the included code and executes that, redirecting based on POST variables, rather than the timeout SESSION variable it encounters first. If I add "die()" after the include on this page, for example, the timeout works, redirecting before executing the die().
So I'm baffled. Any ideas?