Posted By

scottwatkins on 04/19/11


Tagged


Versions (?)

php - Find out if a session with a particular id has expired. - Stack Overflow


 / Published in: PHP
 

URL: http://stackoverflow.com/questions/4753687/find-out-if-a-session-with-a-particular-id-has-expired

  1. <?php $_SESSION['last_seen'] = time();//Update this value on each user interaction. ?>
  2.  
  3. <?php
  4. //Get the session id from file name and store it into the $sid variable;
  5. session_id($sid);//try to resume the old session
  6. if (isset($_SESSION['last_seen']) && $_SESSION['last_seen'] > $timeout){//Session is expired
  7. //delete file
  8. }else if (!isset($_SESSION['last_seen')){ //already garbaged
  9. //delete file
  10. }
  11. ?>

Report this snippet  

You need to login to post a comment.