如何进行循环 - 在会话授权时检查时间是否已过期。我的代码如下所示:
while ($_SESSION['auth']) {
$inactive = 600;
if (isset($_SESSION['timeout'])) {
$session_life = time() - $_SESSION['timeout'];
if ($session_life > $inactive) {
session_destroy();
header("Location: logoutpage.php");
}
}
}
答案 0 :(得分:0)
哇不这样做会让你陷入困境一段时间..
但总而言之,你现在拥有的循环应该有效。
答案 1 :(得分:0)
好的,我已经做了以下事情,也许它可以帮助其他人:
<强>第1页强>
session_start();
///
$teststart = 3600;
$now = time();
$testend = ($now + $teststart);
define(testend1,$testend);
$_SESSION['now2'] = $now;
$_SESSION['testend2'] = testend1;
header('Location:http://localhost/index.php?option=com_content&view=article&id=51');
<强>第2页强>
头部分中的以便页面刷新
<meta http-equiv="refresh" content="300">
然后在第2页
session_start();
if ($_SESSION['auth']) {
$session_testend3 = $_SESSION['testend2'];
$now = time();
if ($now > $session_testend3) {
session_destroy();
header('Location: http://localhost/');
exit;
}
}else{
echo "you are not authorized";
}