1
SUR6E
who's online - time?
  • 2008/9/12 8:29

  • SUR6E

  • Just popping in

  • Posts: 15

  • Since: 2008/9/5 2


How accurate is the Who's Online data? Is it showing who was online the last 5 minutes? Can it be adjusted?

2
ghia
Re: who's online - time?
  • 2008/9/12 9:36

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I believe it takes the session duration from system preferences into account.

For some in realtime displaying block of online users, you may be interested in this. It's live to see on XOOPS Italia under 'Chi è on-line? (Versione Ajax)'.

But beware of the extra traffic and MySQL load!!!

3
trabis
Re: who's online - time?
  • 2008/9/12 13:30

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

ghia_ wrote:
I believe it takes the session duration from system preferences into account.


The online's data does not have a relation with the session's data.

The accuracy of this is handled in system/blocks/system_blocks.php

Look inside for this lines:
mt_srand((double)microtime()*1000000);
    
// set gc probabillity to 10% for now..
    
if (mt_rand(1100) < 11) {
        
$online_handler->gc(300);
    }


This piece of code belongs to the online block and is responsible to delete online entries.
Being more specific:
One in each 10 times(10%) the online's block is renderered it will delete entries older than 5 minutes(300 seconds).

After this code the block just inserts fresh online data for the user that is seeing the page. It is necessary to have the block visible in all pages and for all users for the data to be correct.

Now, if you have very few visitors, you may want to increase the 10% to 50% or even 100% so the block can delete old entries often. Ex:
if (mt_rand(1100) < 51) {


Then you can set the period of time the data is related:
$online_handler->gc(120);


120 will give a 2 minutes(120 seconds) margin, if a user doesn´t refresh a page in 2 minutes it will not appear as online.(this does not affect the session, he could still be logged in)

Login

Who's Online

290 user(s) are online (243 user(s) are browsing Support Forums)


Members: 0


Guests: 290


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits