2013-02-10 47 views
0

这是我的代码,在30分钟不活动后结束sessión,在Linux中正常工作,但在Windows中无法正常工作。30分钟后脚本会话超时,在Windows中不起作用

创建会话

$_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

尝试致电:

session_cache_expire($max_time); 

这将增加会话超时。