Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP : Auto expire session / Auto logout after specific time
<?php
//on pageload
session_start();
$idletime=60;//after 60 seconds the user gets logged out
if (time()-$_SESSION['email']>$idletime){
session_destroy();
session_unset();
header('Location: ../index.php');// relocating user to home page
}else{
$_SESSION['email']=time();
}
//on session creation
$_SESSION['email']=time();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.