hackalive Posted June 7, 2011 Share Posted June 7, 2011 Hi Guys, I need to (through a MySQL Database) log users "activity" basically need to know if they are active or not. I am building a chat script like that of Facebook and need to figure out how they do the "online" "offline" thing for users. So my DB would need to track session activity (I think). If any one can help, or provide links that would be much appreciated. Cheers Quote Link to comment Share on other sites More sharing options...
revraz Posted June 7, 2011 Share Posted June 7, 2011 A common answer to this, is store a time stamp of their activity, then check it for a time frame (say 5 mins) then show them as active or not based on that. This is answered almost weekly, so you should find ideas about this topic already in the forums. Quote Link to comment Share on other sites More sharing options...
Adam Posted June 7, 2011 Share Posted June 7, 2011 To add to that, if this is a JS-based chat room like most are, you will need to use AJAX to periodically send a request to the server to check their last activity. Quote Link to comment Share on other sites More sharing options...
hackalive Posted June 7, 2011 Author Share Posted June 7, 2011 Any suggestions on how to do the AJAX code? Quote Link to comment Share on other sites More sharing options...
Adam Posted June 7, 2011 Share Posted June 7, 2011 Do you know anything about AJAX? Quote Link to comment Share on other sites More sharing options...
hackalive Posted June 7, 2011 Author Share Posted June 7, 2011 some Quote Link to comment Share on other sites More sharing options...
Adam Posted June 7, 2011 Share Posted June 7, 2011 Well the AJAX isn't the difficult bit -- AJAX is in theory is very simple, and jQuery.ajax makes it even easier. All you need to do is set a timer interval to execute an AJAX request to a PHP script, that would query the database for the status of the user's friends and return the data in JSON format. The JS would then receive that data and update the HTML to match the new statuses. The logic is fairly simple, just tackle it one step at a time. If you get stuck, by all means post here with a specific problem. Quote Link to comment Share on other sites More sharing options...
hackalive Posted June 7, 2011 Author Share Posted June 7, 2011 "A common answer to this, is store a time stamp of their activity, then check it for a time frame (say 5 mins) then show them as active or not based on that. This is answered almost weekly, so you should find ideas about this topic already in the forums." Okay so how with PHP do I log activity, etc? I need a clean neat way of doing it. Quote Link to comment Share on other sites More sharing options...
revraz Posted June 8, 2011 Share Posted June 8, 2011 Every action someone does, you log it in the DB with the time and their ID 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.