[英]How to test session timeout in php?
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'])
print_r($_SESSION)
和print_r($_SESSION['timeout'])
you can var_dump( $_session );
你可以
var_dump( $_session );
after your if/else statement and see if $_session['timeout']
is set or has a value.在您的 if/else 语句之后,看看
$_session['timeout']
是否已设置或具有值。 following session_destroy()
the session should be empty.在
session_destroy()
,会话应该是空的。
update更新
Try changing $_session
to $_SESSION
.尝试将
$_session
更改$_session
$_SESSION
。 This is a special PHP variable and case may matter这是一个特殊的 PHP 变量,大小写可能很重要
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.