这是我在30分钟不活动后结束sessión的代码,在Linux中工作正常但在Windows中没有。
创建sessión
$_SESSION['clientdan']['user'] = $username;
$_SESSION['clientdan']['tl'] = time();
any_file.php
<?php
session_start();
$max_time = 1800;
$current = time();
if(!isset($_SESSION['clientdan']['user']) ) {
header('Location: index.php');
} else {
if (!isset($_SESSION['clientdan']['tl'])){
$_SESSION['clientdan']['tl'] = time();
} else {
$session_life = $current - $_SESSION['clientdan']['tl'];
if ($session_life > $max_time) {
header('Location: include/logout.php');
} else {
$_SESSION['clientdan']['tl'] = time();
}
}
?>
<!DOCTYPE html>
......
......
<?php } ?>
答案 0 :(得分:0)
尝试致电:
session_cache_expire($max_time);
这会增加会话超时。