Page 1 of 1
php chat room login/logout problem
Posted: Thu May 02, 2002 8:00 pm
by g8z
I'm developing a chat room that will have a list of users who are logged-in
Logging out can be done by clicking "log-out" or by simply closing the web
browser
How would one detect that the client's browser is no longer open to the chat room, if they decide to just close the browser instead of clicking the
"log-out" link?
Thanks,
Darren
Posted: Thu May 02, 2002 10:05 pm
by dusty
compare an idle time to a set timeout period of time and remove names from the list where idle time > timeout time.
Posted: Thu May 02, 2002 10:16 pm
by hob_goblin
Attribute for <BODY ...>
onUnload = "script command(s)"
im just guessing but maybe you could execute a function or something using the <body onUnload=""> tag...
Posted: Thu May 02, 2002 11:28 pm
by dusty
i wouldn't suggest relying on unLoad for logging out. maybe using that first and have a timeout set just to back it up. but don't depend on just the unLoad.
Posted: Fri May 03, 2002 2:50 pm
by hob_goblin
yeah, you could do the timeout as well to be safe, but onUnload would make it a tad bit more accurate, if accuracy matters the most..
Posted: Fri May 03, 2002 2:55 pm
by Jim
Probably a stupid question, but how does one code a chatroom in PHP? Are there any tutorials? This is a very, very interesting prospect...
It would fit perfectly with a program I am writing.
Thanks!
Posted: Fri May 03, 2002 2:57 pm
by hob_goblin
pretty simple after you get the logging in and out finished...just write to a file and have it load into a frame or table, and make the frame or table refresh often, or after every post
Posted: Fri May 03, 2002 3:10 pm
by dusty
i never saw a php chat room as being a good idea. using refresh tags are annoying unless you're printing in flash, but IMHO i'd still stick to java for chat rooms.
as for the unload tag being more accurate, i'd say that THAT would be the backup for the more accurate comparing of the times. relying on a client to log himself out isn't accurate at all. if they don't have javascript enabled, or just closes the page and closes the loaded page on unload before the logout takes place then you still have a person logged in that has already left, where as if you have a set timeout period and compare his last action to that time, you are almost certain to drop all of the people who just left w/o logging out.
stick to flash or java for the printing to be sure you get rid of them though. strictly php/html display is a bad idea. even if you use the timeout idea. having a short set timeout period would mean people would have to talk alot or they get removed. having a long timeout period would mean that if someone left right after their last statement and the unload script didn't go through, you have someone in your chat room that has left long ago.
Posted: Fri May 03, 2002 5:22 pm
by hob_goblin
dusty wrote:i never saw a php chat room as being a good idea. using refresh tags are annoying unless you're printing in flash, but IMHO i'd still stick to java for chat rooms.