php - 会话超时卡在循环中
问题描述
我陷入了会话超时循环,
一旦会话超时,我就无法重新登录
<?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
解决方案
在重定向之前尝试取消设置会话变量
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
推荐阅读
- spring-boot - @DataNeo4jTest 的 UnsatisfiedDependencyException
- laravel - Laravel belongsToMany 获取数据透视表附加属性数据
- python - 使用python将excel对象嵌入到PPT幻灯片
- sql - 如何在月度数据系列中查找缺失的日期?
- javascript - 如何在 JavaScript/Node.js 中获取选中复选框的所有值
- node.js - 猫鼬是如何出口的?
- ios - __block 变量在方法调用时返回 nil
- javascript - 在 JavaScript 中循环遍历数组中每个对象的每个属性值
- sql - 将 MAX() 和 COUNT() 与 HAVING 一起使用
- php - 完整的日历显示月事件,但不显示周/日时间网格