Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catching time user leaves application

Status
Not open for further replies.

dpdg

Programmer
May 23, 2005
148
US
I want be able to record the time a certain user leaves the site. If he uses the Logout button to close the application, I can record it, but what if he closes the browser window to close it?

Is there any way that I can catch it with something like the "unload" event? Or maybe trigger something from javascript?
 
You can only do this with a client-side language (such as javascript) and it won't work if the user has javascript disabled or they have a pop-up blocker on.

It's really not a good route to go down...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
All of my users will have javascript enabled since they will all be working for the same company -- I can depend on that. This is not a problem in my case.

The client just wants to keep track of the times that users log into and out of the application -- this information is of no interest to me.

How would I get the logout time in javascript when they application by closing the browser ?
 
You'd have to use a javascript pop-up that fired on the unload of the page. The pop-up would have to open a window that executed a sql statement on the Page Load event.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
And in addition, note that if the user kills the browser process via Taskmanager, the javascript event won't fire and you won't get your log-out time.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
That's a remote possibility, but the time is not really crucial -- it's merely to see how much the application is getting used.

The most important part is getting user names and login times. How long they stay on is not that big of a deal.
 
So why log the end time at all? Surely the login will suffice?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
What about using the Session_End event in Global.asax? It's dependent on your session timeout, but it'll catch those who don't logout explicitly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top