PHP How can I find if there's been any request/activity in the past 15 minutes?
<p>When user closes the browser and the session gets killed, I need to update my database of current users. So I have set up a simple cron job that deletes the row.</p>

<pre><code>DELETE FROM visit WHERE unix_timestamp(time)&lt;unix_timestamp(now()-600) and sessionid &lt;&gt;(LIST OF SESSIONS ..need help)
</code></pre>

<p>I can get the session files thanks to this code provided here on StackOverflow(thanks)</p>

<pre><code>$sessions = array();

$path = realpath(session_save_path());
$files = array_diff(scandir($path), array('.', '..'));

foreach ($files as $file)
{
$sessions[$file] = unserialize(file_get_contents($path . '/' . $file));
}

echo '&lt;pre&gt;';
print_r($sessions);
echo '&lt;/pre&gt;';
</code></pre>

<p>My question is are those files returned by the second half of the code the list of active sessions? Basically I'm trying to verify that all the rows that will be deleted will contain sessions that are not part of the "ACTIVE' list supposedly returned by    unserialize(file_get_contents($path . '/' . $file));</p>

<p>I have read that another approach would be to check the last activity timestamp (if it's greater than say 10 minutes). But I don't know how to record "last activities' onto the database. </p>

<p>Thanks</p>
