Hi, I’ve been working on a site lately. I have the majority of it done but I’m running into an issue with online sessions. Atm I’m storing each session into the database when the user Logs in, then when they log out it deletes the session. I’ve seen several tutorials using time stamps to delete the session after a certain amount of time. But since that would end the session after 20 minutes and put the player offline. I was wondering if doing a Crontab and maybe a loop through all the sessions like every 5 minutes to check if they are still valid or not. I started up a little something, Idk if it’ll work though. Does anyone have any ideas?
session_start();
require_once("/*Connect to Db*/");
$result = mysql_query("SELECT * FROM Online");
while($row = mysql_fetch_array($result)) {
if(!isset($_SESSION[$row['User']])) {
mysql_query("DELETE FROM Online WHERE User = '".$row['User']."'");
}
}