tracking date & time of logout user

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
amlan_08
Forum Newbie
Posts: 11
Joined: Sun May 22, 2005 1:24 am

tracking date & time of logout user

Post by amlan_08 »

I have to develop a login system where I have track the user login & logout date & time. Now my prob. is if a user just close the browser without logout the how I track that time. Is there any way to track that time. I am using mySQL in as my database.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Come up with a timeout, say 120 seconds.. If a user hasn't done anything in 120 seconds, use his last page view as the official logout time.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

If its really important, have an invisible image that updates the last time it was loaded in a database, and then have javascript refresh the image every 1 second. In 99% of cases its very unneccessary to do it this way, but I don't really know your situation - so thats how to solve it.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

How precise do you want it? You could just run a cron job every minute or so to see whether you have any inactive users (users who may have potentially closed the browser or have no performed any actions in the last X minutes. The problem is what if the user is simply reading an article on your site or something -- and out waited the maximum logout time buffer and logged himself out when he didn't want to.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not use database sessions? You should have a "last updated" type field in that table.


At any rate, this is not for the general dicussion board; moved to PHP - Code.
Post Reply