首页 > 解决方案 > 会话超时卡在循环中

问题描述

我陷入了会话超时循环,
一旦会话超时,我就无法重新登录

<?php
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 300)) {
    header("location:../index.php");
    exit();
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
?> 

这是我包含 timeout.php 的地方

 <?php
//$now = 0;
if (isset($_REQUEST['err'])){
$now = $_REQUEST['err'];
}
?>
<?php
session_start();
include('../includes/session_timeout.php');
if(!isset($_SESSION['isactive'])){
    header('location: index.php?e=li');
}
include('../../administrator/includes/constants.php');
include('../includes/functions.php');
if(isset($_REQUEST['p'])){
    $cmd = $_REQUEST['p'];
}else{..........etc

标签: php

解决方案


在重定向之前尝试取消设置会话变量

session_start();
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 300)) {
unset($_SESSION['LAST_ACTIVITY']);
header("location:../index.php");
exit();
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

推荐阅读