Return to Snippet

Revision: 66184
at March 26, 2014 05:32 by kidmizere


Initial Code
session_start();
// set timeout period in seconds (600 = 10 minutes)
$inactive = 600;
// check to see if $_SESSION['timeout'] is set
if(isset($_SESSION['timeout']) ) {
	$session_life = time() - $_SESSION['timeout'];
	if($session_life > $inactive)
        { session_destroy(); header("Location: logoutpage.php"); }
}
$_SESSION['timeout'] = time()

Initial URL
http://www.daniweb.com/web-development/php/threads/124500/session-time-out-in-php

Initial Description
This is a neat little process for setting a timer and ending a session - change time to reflect minutes for timeout, change redirect to your logout page

Initial Title
Session Timeout

Initial Tags

                                

Initial Language
PHP