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

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. <?php $_SESSION['last_seen'] = time();//Update this value on each user interaction. ?>
  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


RSS Icon Subscribe to comments

You need to login to post a comment.