Why doesn't this code work?
session_start();
// 5 mins in seconds
$inactive = 300;
$session_life = time() - $_session['timeout'];
if($session_life > $inactive)
{
session_destroy(); header("Location: client_login.php");
}
else
{
$_session['timeout']=time();
}
Check :
print_r($_SESSION)
and print_r($_SESSION['timeout'])
you can var_dump( $_session );
after your if/else statement and see if $_session['timeout']
is set or has a value. following session_destroy()
the session should be empty.
update
Try changing $_session
to $_SESSION
. This is a special PHP variable and case may matter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.