Wednesday 11 March 2015

inactive user session expire in php

 <?php

$expireAfter = 5; //expire session after 5 mints.
if(isset($_SESSION['last_action'])){

    $secondsInactive = time() - $_SESSION['last_action'];
  
  
    $expireAfterSeconds = $expireAfter * 60;
  
  
    if($secondsInactive >= $expireAfterSeconds){
        unset($_SESSION['vendor']);
    }
  
}

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

?>

No comments:

Post a Comment