session timeout due to inactivity
<p>I have created a script <code>login.php</code> and there I have created a session variable named <code>logged_in</code></p>

<pre><code>$_SESSION['logged_in'] = true;
</code></pre>

<p>I am unable to figure out a way to redirect to redirect to my logout.php after session expires due to inactivity. Also should I put the code that expire this session variable. I have Googled the bug and what it suggest is to tweak <code>php.ini</code> file in most of the articles. However I came across an article saying that it is not the best practice.<br /><br />
I found the following code on StackOverflow, yet I have no idea where to put it:-</p>

<pre><code>&lt;?php
  if ($_SESSION['timeout'] + 10 * 60 &lt; time()) {
     // session timed out
  } else {
     // session ok
  }
?&gt;
</code></pre>

<p>I would like to know the best way to redirect after session expire and suggestions for where to put the code.<br /><br />
Edit: I forgot to mention that I want to know how to manually set a time for the session to expire.<br /><br />
Thank you in advance</p>
