Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(!isset($_SESSION['user_id']))
- {
- /* Redirect If Not Logged In */
- header("Location: Login.php");
- exit; /* prevent other code from being executed*/
- } else {
- /*we are going to start tracking a new session variable we will call timeout.
- by comparing the session timeout plus 600 seconds to the current time,
- we can force users to the logout page when they attempt to access the page, after 10 mins of inaction*/
- if ($_SESSION['timeout'] + 10 * 60 < time()) {
- /* session timed out */
- header("Location: Logout.php");
- } else {
- /*if the user isn't timed out, update the session timeout variable to the current time.*/
- $_SESSION['timeout'] = time();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement