php chat room login/logout problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
g8z
Forum Newbie
Posts: 3
Joined: Thu May 02, 2002 8:00 pm

php chat room login/logout problem

Post 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
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

compare an idle time to a set timeout period of time and remove names from the list where idle time > timeout time.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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...
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post 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.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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..
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Post 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!
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post 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.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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.
Post Reply