If you use http://php.net/session_start, I guess you could declare that your session timeout *IS* the definition of current users... But, really, even at 5 minutes, you may be counting a lot of people who have LEFT your site. There is no "real" number for this. Do whatever you want. On Mon, February 5, 2007 6:35 am, benifactor wrote: > i have built a function to tell me how many users are on my site at > any given time... > <? > > //define function > > function bc_who ($who, $location) { > > > //first we erase any expired entries > //entries will expire after 5 mins > $whoTime = time(); > $whoTime = $whoTime - 300; > mysql_query("Delete FROM bc_who where expire < $whoTime") or > die(mysql_error()); > > //here we difine the variables needed to preform the check > $whoExpire = time(); > $whoIp = "$_SERVER[REMOTE_ADDR]"; > > //this will be changed as soon as user registration is finished > $whoUser= "Guest"; > //do the actual mysql queries > > mysql_query("Delete FROM bc_who where '$whoIp' = ip"); > mysql_query("Insert INTO bc_who (id, user, ip, location, expire, > status) VALUES (NULL, '$whoUser', '$whoIp', '$location', > '$whoExpire', '$whoStatus')"); > > > } > > //end who is function > > ?> > > this fuction works fine, however, i want to know if what i am about to > ask is possible. > > the problem i have is, this function assumes that after five minutes > if the user has not refreshed the page, or gone onto another page the > user must be gone. in reality, i have pages users might be on for an > hour or so without refreshing. i want my whos online to as acurate as > possible so is there a way to do this on the fly? like, forgetting > about the expire time and using a server side peice of code to > communicate to the database, when there is no more communication the > entry is deleted? please tell me there is a way, thank you in advance. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php