Last active
August 29, 2015 13:57
-
-
Save GiovanniGrieco/9414628 to your computer and use it in GitHub Desktop.
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 | |
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