studygirl15 Posted May 20, 2009 Share Posted May 20, 2009 Hi. Can anyone tell me how I would output a list of players who are online, and have done something in the last 5 minutes? How would I monitor that... first of all.. Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 20, 2009 Share Posted May 20, 2009 Have a table with `Username` and `Unixstamp` or someting. Then record the unix stamp of each player in the database on every page visit. Then work out who's online by fetching all rows with a `Unixstamp` >= time() - 600 or whatever limit you want to time people out with. Quote Link to comment Share on other sites More sharing options...
studygirl15 Posted May 20, 2009 Author Share Posted May 20, 2009 Do you think you can dumb that down a little for me Quote Link to comment Share on other sites More sharing options...
Masna Posted May 20, 2009 Share Posted May 20, 2009 Do you think you can dumb that down a little for me I don't think that's possible. Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 21, 2009 Share Posted May 21, 2009 Lol. Uhh...ok, Make a table. On each page request, make a query that updates a field with a timestamp. Then you can determine whether a user is online by checking when they last requested a page. That's what I do on my site. It's pretty straight forward. But yeah, have a go. If you get stuck with something specific, just post back. Quote Link to comment Share on other sites More sharing options...
studygirl15 Posted May 22, 2009 Author Share Posted May 22, 2009 ok... so.. i make a table... then i put some code.. which i can find on google.. on the top of all like 40 pages i have made... and the code reads the cookie of the user.. to see which one it is.. and then it like does something magical.. and bam there is a time in the table.. and after how many seconds.. the time thingy expires and disapeers.. and everyime the user visits a new page.. it updates the time thingy... correct? Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 22, 2009 Share Posted May 22, 2009 Kind of... Ok, make one file with something like this in: $username = $_COOKIE['username']; $timestamp = time(); mysql_query("INSERT INTO `user_timestamps` (`username`, `timestamp`) VALUES ('$username', '$timestamp') ON DUPLICATE KEY UPDATE `timestamp`='$timestamp'"); And include that on every page. Then you can figure out who's online with something liek this: $time = time() - $limit;//$limit is how many seconds you allow users to not have made a page request before they are considered "offline" $sql = mysql_query("SELECT * FROM `user_timestamps` WHERE `timestamp`>='$time'"); //do whatever... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.