when a user close the browser without login

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
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

when a user close the browser without login

Post by djdon11 »

Hello Friends.
I am facing a problem
actually i have to show my user that who is online and offline right now for this i am using a database table. when user login than i make a entry of this record along with the user id and date time. and using these records i can show who is online.
when user logout through logout link than i delete the record along with this userid.

my problem is when user close the browser without logout link than user get logout but the entry which is in the database table is not deleted. as the user does not goes over the logout page and the delete query is not executed..
can anybody suggest me any solution that how i can execute my delete query when user goes logout via the browser closed.


thanks in advance
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: when a user close the browser without login

Post by onion2k »

You can't. If the user closes the browser window without logging out there is no way to tell. You have to record the time the user last interacted with the site and assume that they've logged out after a certain time eg 5 minutes with no activity.

Is this a class assignment for college or something? We've had this question asked here a few times in the past week. If it is, why don't you talk to your classmates?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: when a user close the browser without login

Post by aceconcepts »

I don't see a problem with logging a user out after a certain period of time.
Post Reply