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

Howdy, Stranger!

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

Categories

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

Damian99Damian99 USAPosts: 116Member

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

Tagged:

Comments

  • DavidMDavidM USAPosts: 342Member
    $_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.