Skip to content

Instantly share code, notes, and snippets.

@GiovanniGrieco
Last active August 29, 2015 13:57
Show Gist options
  • Save GiovanniGrieco/9414628 to your computer and use it in GitHub Desktop.
Save GiovanniGrieco/9414628 to your computer and use it in GitHub Desktop.
<?php
define("TIMEINTERVAL", 60); // define the interval in seconds
//we have a session, so I call it
session_start();
// if the user have not visited a page under an interval of 60 seconds, destroy the session
if ( (time() - $_COOKIE['session_time']) > TIMEINTERVAL ) {
// log out the user from the session and redirect it to a page
session_destroy();
header('Location:a/page.php');
} else {
//register or update a cookie if interval < 60 seconds
unset($_COOKIE['session_time']);
setcookie( 'session_time', time() );
}
// ... code ...
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment