2013-02-10 66 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); 

這將增加會話超時。