I’m making a visitors online for a wordpress blog and I am logging a session hash in mysql database (I’m using a session hash created by vbulletin as it is integrated with my wordpress)
if (isset($_COOKIE['bbsessionhash'])){
//insert to databse query + current time
}
how do I delete this data from mysql every 5 mins. I’m not asking for exact code just an idea…
It might not be important to actually delete it on time. You could just filter out the records that are older than 5 minutes when doing a select. Cleanup never needs to be done then, or you could do it on a less rigid schedule.
But, if you really need to delete, run a cron job every 5 minutes.
when visitor visits the site 1 session is inserted in the databse with current time and expiry time. When another visitor visits the site php will check all the sessions and check if it has expired if it is it will mark it expired.
then my query looks something like this
$q =mysql_query(“SELECT stats FROM table WHERE stats !=‘expired’”);
$number_of_visitors = mysql_num_rows($q);
echo '$number_of_visitors;
Cheers, I know there are tons of better solution than this but I’ll stick with it.
’