Reply to Re: show list of users online

Your name:

Reply:


Posted by Jerry Stuckle on 08/22/07 02:56

Yukino wrote:
> How can i list the users logged into the system?
>
> Maybe save the list of session id in application attribute?
>
>
>

Short answer - you can't. You can tell when someone logged on, but not
if they're still on the site.

Longer answer - no, there are no "application attributes". You can
implement your own session handler, which can then save the login id (or
even all of the session data) in a database, and clean it up when the
session is closed. It's a bit of work, but once you have it working you
don't have to do anything on the rest of your pages (other than normal
things like calling session_start).

Easier, but generally requiring more work would be to have your logon
page add a row to a database, and your logoff code remove it. Then each
page, right after the session_start(), could update the row with the
current timestamp (which could all be in an included file)

Have a cron job which runs every few minutes and deletes any entry more
than x minutes old - where x is the same as your session timeout value,
for those who do not log out.

Now you can count the rows in your table and know how many are logged
on. Not foolproof - but since HTML is a stateless protocol, there is no
guarantee the person even still has his computer on (i.e. he might have
just hut down without logging off).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация