Members On Script
Posted: Sat Jul 26, 2003 8:43 pm
Is there any way to keep track of when a person clicks out of the current page?
Example: If a member clicks a page on my site, it will show up that he is currently on that page, and when he loads a new page, it doesn't show up anymore?
I have something like it for my site currently. Members who are currently logged on. Its a simple time function. If you logged in, in the last hour, you are "online." I'd like it more exact, but I don't quite know how to do it. This is my current function, roughly.
Log.php:
Logoff.php
Thanks!
-Dani
Example: If a member clicks a page on my site, it will show up that he is currently on that page, and when he loads a new page, it doesn't show up anymore?
I have something like it for my site currently. Members who are currently logged on. Its a simple time function. If you logged in, in the last hour, you are "online." I'd like it more exact, but I don't quite know how to do it. This is my current function, roughly.
Log.php:
Code: Select all
<?php
$timenow = time();
$sql = ("UPDATE members SET atime='$timenow' WHERE mid='$mid'")
or die ("cannot select updae active time");
$result = mysql_query($sql);
$sql = ("UPDATE members SET logged_on='1' WHERE mid='$mid'")
or die ("cannot select updae active time");
$result = mysql_query($sql);
?>Code: Select all
<?php
$timenow = time();
$result = mysql_query("SELECT mid, atime FROM members WHERE logged_on='1'")
or die ("cannot select last logged in time");
while ($row = mysql_fetch_array($result))
{
$mid = $row["mid"];
$atime = $row["atime"];
$timediff = $timenow - $atime;
if ( $timediff >= 3600)
{
$sql = mysql_query("UPDATE members SET logged_on='0' where mid='$mid'") or die ('cannot log off membrers');
$sql = mysql_query("UPDATE members SET atime='0' where mid='$mid'") or die ('cannot reset members last active time on the site');
} //end if
} //end while
?>-Dani