Can I log user out after session has reached maxlife
<p>I have a piece of code below where session variables can last for 12 hours:</p>

<pre><code>ini_set('session.gc_maxlifetime',12*60*60);
ini_set('session.gc_divisor', '1');
ini_set('session.gc_probability', '1');
ini_set('session.cookie_lifetime', '0');
</code></pre>

<p>But what my question is that is it possible to log the user out once 12 hours has passed and the session variables have expired? In other words I have a teacherlogout.php page, after 12 hours has passed can it redirect the user to the logout page once the user has navigated to another page or refreshed the page after 12 hours?</p>

<p>UPDATE:</p>

<p>Could this work:</p>

<pre><code>if ((isset($username)) &amp;&amp; (isset($userid))){

...//WHOLE CODE

}else{

header( 'Location: teacherlogout.php' ) ;
}
</code></pre>
