RE: trying to figure out the best/efficient way to tell whoislogged into a site..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ben...

your statements/approach is pretty much what i've been thinking of. however,
with regards to the forums/cms apps.. i've yet to find one that actually
keeps a track of the logged in users, that works when the user kills the
browser..

the ones that i've seen, that allow an admin to see who's online, appear to
fail when i've killed the test user. the apps still show the killed user as
being online...

hence my isuue!

-bruce


-----Original Message-----
From: Ben [mailto:ben@xxxxxxxxxxxxxxxxx]
Sent: Tuesday, September 13, 2005 6:33 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  trying to figure out the best/efficient way to tell
whoislogged into a site..


bruce wrote:

> my question is still how do i determine for a given session, that a user
is
> still on the site, or that the user is no longer on the site/system. i
don't
> see an automated/system way of doing this.

The web is stateless...  There is no automated/system way of doing this.
  You know the last time a user requested a file, that's it.  It's up to
you to determine what's a reasonable timeout between page requests so
that you can determine when someone has gone elsewhere.


> it appears that i might have to capture the session vars in a db, along
with
> the associated time creation. it then appears that i'm going to have to
have
> some way of continually updating the session 'time' to reflect that the
user
> is still on the system/site. this kind of approach could be done via some
> include file for every page that the user hits on the site. i could then
> trigger off this to determine who's live/on the site.

You can keep doing your session variables however you're currently doing
them, just store a timestamp for each user in a db or file and update it
every time the user requests a file.

Your script that tells you how many users are online can then check
against the db/file and count the timestamps less than $timeout seconds
old, which will be your "users online".  The script should also do
garbage collection for any entries with timestamps older than your $timeout.

> the downside to this is that i could kill someone who might be on the
> system, but just not actively using the site.. maybe they stepped away...

So have $extended_timeout which is a ridiculously long time out period
during which users are marked as stale, but not deleted.  If they
request a file during the $extended_timeout you start counting them
again, if they don't then after the $extended_timeout they are deleted.

> now, if there was/is away to examine the session var that i store using
the
> session handler, such that i could determine which session var is still
> alaive.. then that would solve my issues!!!!

Not really... Sessions are no more or less likely to be accurate for
counting users on your site than what I've described above.  They too
time out after a period of time (set in php.ini) and are then subject to
garbage collection.  They hang around long after the user.

>
> however, as i've stated, i can't find any code sample/articles that get to
> this point..
>
> any code/thoughts/comments/etc...

Most forums have some type of "who is online" functionality, have a look
at how they do it.

- Ben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux