i have this php code below:
i want to display users that are online . if they are not active the next 20 min then there name will not be displayed and there status will be turned OFF in th database table tng_users field status
but i also want all session to be cleared when this users status turn OFF because that means he wont be online or active and i want him clear all the sessions when his status turn to OFF.
how do i do that??
thanks!!
?>
$gap=20; // change this to change the time in minutes, This is the time for which active users are collected.
$tm=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
//// Let us update the table and set the status to OFF
////for the users who have not interacted with
////pages in last 20 minutes ( set by $gap variable above ) ///
require('online_connect.php');
$ut=mysql_query("update tng_users set status='OFF' where tm < '$tm'");
echo mysql_error();
$test = mysql_query("SELECT * FROM tng_users WHERE status='ON'");
$num_rows = mysql_num_rows($test);
if ($num_rows == 0){
echo "sorry,there are no users online!";}
$whoo = mysql_query("SELECT username,country FROM tng_users WHERE status='ON'");
while($username = mysql_fetch_array($whoo)){
echo "$username[username]..$username[country]";
echo "<br/>";}
//}
?>