Tracking Users

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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Tracking Users

Post by Gen-ik »

I have a chat room. Members must log-in to access the chatroom. I am trying to work out how to check if member is still in the chatroom or has left.. either by loging-out (I can sort that bit out) or by closing the browser/jumping to another site (which I'm having trouble with)

Any ideas or pointers?

Thanks.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

i'd use sessions, and session timeouts... but also for quicker access

try the <body onUnload=""> attribute... it will work 85% of the time and help alot
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

hi hob_goblin,

i m very much keen to know about the 15% part for cleanup/user tracking.

i think, after session, session timeout and <BODY unLoad=""> there remains only crash (windows favorite ;-) conditions.... which we can't do much about.

regards,
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Well, if a person crashes, their really is nothing the system can do. Basically, the best it can do is after 5 minutes and the chatroom hasn't gotten an update from the person (like with an auto-refresh), the person has "timed out".
Tzicha
Forum Newbie
Posts: 8
Joined: Wed Sep 04, 2002 9:54 am

Post by Tzicha »

Working with jason's suggestion:
1. When a user logs in the site, set a variable to the login time.
2. Upon each access, compare the variable set in 1 to the current time, if the difference is greater than your timeout limit, log out the user
3. For those that just leave the site, or close the browser (crashes not withstanding) try a combination of things:
3a. Use an unLoad javascript tag to close the user session
3b. Have the session perform clean-up duties when it times out

There are probably other ways besides the ones mentioned.
Post Reply