How to let a PHP session expire after a time set by the application?

Please let me know how to keep a PHP session for a pre-defined time and then delete it.


  • $_SESSION['startTime'] = time(); // current time
    // end the session in 50 mins
    $_SESSION['expireTime'] = $_SESSION['start'] + (50 * 60);

    Then check the current time with the$_SESSION['expireTime']when you want to check for a user login validation or any other form of validation.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion