Skip to content

Instantly share code, notes, and snippets.

@selwynorren
Created October 10, 2019 10:27
Show Gist options
  • Select an option

  • Save selwynorren/6a284b813ba9ccb7b24034f7603831d8 to your computer and use it in GitHub Desktop.

Select an option

Save selwynorren/6a284b813ba9ccb7b24034f7603831d8 to your computer and use it in GitHub Desktop.
PHP Session expire / Logout after time
<?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