Jump to content

Current amount of users online?


strobic

Recommended Posts

No AJAX needed, just setup your system to store PHP sessions in the database, this will mean that you have a sessions tabe and there will be a field for the timestamp of the last request. All you need to do is run a query to pull out the number of sessions (rows) that have a timestamp in the last say 10 minutes.

 

There is a way to increase the accuracy with AJAX, which is to (within your page) call one of your scripts every say 1 minute, which will update the session timestamp, then of course if a user closes the page, the AJAX call will no longer run and the timeout won't be updated, so you can assume the user is not online if the timeout is older than a minute.

 

Personally I won't bother with the AJAX though, I would just look at the table and see who was updated in the last 10 minutes.

Link to comment
Share on other sites

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.