Created
April 9, 2015 14:31
-
-
Save ryanemitchell/dac3eb04a8665c3bf2f2 to your computer and use it in GitHub Desktop.
Auto expire session / Auto logout after specific time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//on pageload | |
session_start(); | |
$idletime=60;//after 60 seconds the user gets logged out | |
if (time()-$_SESSION['timestamp']>$idletime){ | |
session_destroy(); | |
session_unset(); | |
}else{ | |
$_SESSION['timestamp']=time(); | |
} | |
//on session creation | |
$_SESSION['timestamp']=time(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment