Jump to content


Photo

Session timeout

session

  • Please log in to reply
1 reply to this topic

#1 wmeredith

wmeredith

    Member

  • Members
  • PipPip
  • 23 posts

Posted 25 September 2013 - 02:30 PM

Hey guys if the user exits the browser will this code still run the user_logout.php ? 

 

Thanks


session_cache_expire( 20 );

session_start(); // NEVER FORGET TO START THE SESSION!!!

$inactive = 1200; //20 minutes *60

if(isset($_SESSION['start']) ) {

$session_life = time() - $_SESSION['start'];

if($session_life > $inactive){

header("Location: user_logout.php");

}

}

$_SESSION['start'] = time();



if($_SESSION['valid_user'] != true){

header('Location: ../....php');

}else{ 


#2 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,539 posts

Posted 25 September 2013 - 02:39 PM

Simple answer no. You can not reliably detect when the browser window is closed. The server only parses PHP files when they are requested.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com