Hi,
I have a timeout script which I'm currently having problems with. Basically if a user is on the login page [but hasn't logged in yet] and is inactive for longer than 15 minutes, then decides to login - they are automatically redirected to the timeout.php page.
What I would like the script to do is only go to the timeout.php page if the user is logged-in and inactive. My code is below:
<?php
if (isset($_SESSION['loggedIn']))
{
// set timeout period in seconds
$inactive = 900;
// 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: timeout.php"); }
}
$_SESSION['timeout'] = time();
}
?>
Any help would be greatly appreciated.