|
Posted by Erwin Moller on 02/16/07 14:20
Mitul wrote:
> Hello everybody,
>
> I am developing a community site and almost all works are competed.
> There is major issue that I am facing is how to track user's online
> status. I am using session data to save user's login status. There are
> 2 major issues which I need to handle for tracking user's Online
> status.
>
> 1. When login user close his/her browser.
> 2. When session time out.
>
> Both of above case I need to update a field in database which holds
> user's online status. I am really stuck on this.
>
> Please help me.
>
> Any help or suggestion are welcome.
>
> With Regards,
> Mitul Patel.
Hi Mitul,
Enter the great adventure of Database based sessionstorage.
It is the best way I know of.
Instead of PHP's default sessionstorage (serialized sessions in files), you
can also store them in a DB.
If you are interested, start here:
http://nl2.php.net/manual/en/function.session-set-save-handler.php
Add some housekeeping to it when you build it (look at garbage collection
routines). It is all very straightforward once you have a database that
holds the sessions.
But don't expect that PHP automagically knows when a user closes the window.
No event is send to PHP when that happens, so you are stuck with your
default session time-out to know if a user is online.
Regards,
Erwin Moller
[Back to original message]
|