Jump to content

Recommended Posts

well, other than a session, some AJAX or a refreshing iframe every 15 minutes to tell your server they're active, and every 15 minutes clear ppl who havn't updated in 15 minutes, but sessions would most likely be better

well, other than a session, some AJAX or a refreshing iframe every 15 minutes to tell your server they're active, and every 15 minutes clear ppl who havn't updated in 15 minutes, but sessions would most likely be better

So you're saying to use AJAX and a database? Inserting people who are there, then removing them if they're not there the next check?

well, if they're not there.. than AJAX won't trigger, then they wouldn't get removed.. use ajax to keep updating the timestamp in teh database, and another time as the start time of the server, just make the table have 4 fields

 

ip | randomly_generated_number | last_active | server

 

and IP would be ofcourse their IP, randomly generated number would be a number randomly generated by the page, to know that they are the person who should be accessing that db entry, last active would be a simple timestamp, server would be true or false, being your server or not

 

set server to some number in the past, and then do a query every request from the ajax

 

like

 

if (mysql_fetch_array(mysql_query('SELECT * FROM `table` WHERE `server` = true AND `last_active` < (UNIX_TIMESTAMP(NOW()) - (60 * 15))'))) {

  mysql_query('DELETE FROM `table` WHERE `last_active` < (UNIX_TIMESTAMP(NOW()) - (60 * 15)) AND `server` = false');

  // clear up table

}

Just run a check every 5 minutes like Russell mentioned to check if they are active. Something like setup a php script that will retrieve your count() and echo it. Then if you wanted have a JavaScript call that php script in whatever time you designate. By using AJAX you would be able to retrieve the value echoed from your php script in the JavaScript variable.

 

 

Hope that makes sense.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.