PHP - Destroy session if not any action in 10 minutes

Eli_Rozen picture Eli_Rozen · Jan 29, 2012 · Viewed 30.9k times · Source

Is there any option to destroy a session if user does not perform any action in 10 minutes?

Answer

ose picture ose · Jan 29, 2012
session_start();

// 10 mins in seconds
$inactive = 600; 

$session_life = time() - $_session['timeout'];

if($session_life > $inactive)
{  session_destroy(); header("Location: logoutpage.php");     }

S_session['timeout']=time();

The code above was taken from this particular page.