Page 1 of 1

tracking date & time of logout user

Posted: Sat Aug 13, 2005 11:13 am
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.

Posted: Sat Aug 13, 2005 11:18 am
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.

Posted: Sat Aug 13, 2005 11:25 am
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.

Posted: Sat Aug 13, 2005 1:09 pm
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.

Posted: Sat Aug 13, 2005 2:41 pm
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.