Detect moment when user closed session

N

NWx

Hi,

I have the following question:

I have an app that uses user login/logout to identify users
When user logon, I register logon time in a session variable
When user logoff using the logout link, I also register logoff time and
update accordingly the logging history table.
However user can simply close the browser without logoff, so his session was
closed.
Is there any way to detect when this is happening, to allow me to get the
time and update logoff time field appropriate?

Thank you.
 
M

Michael Ramey

I don't believe what you are trying to do can be done accurately, with a
100% success rate (since it would require some client coding). If a client
wants to close their browser and not let the server know about it, they most
certainly can do that. You could try some crude javascript code to pop up a
window when the browser is closing which would execute some logoff code, but
with all the nice popup blockers these days...good luck.

Here's another option, and I'll leave it to you to implement if you want to.
For each page the user requests after the he is logged in, remember the
time, that time is the logout time, unless you get another request. You
could add a minute or so to it if you want to give the impression that the
user stayed there and looked at the page for a minute. Now look at the
session_end method in the global.asax file. Somehow set your logging
history table with this value when this method fires.

HTH,
--Michael
 
N

NWx

Thank you for your answers.
I thought about popup window, but you are right with the popup blockers.

I'll try your second suggestion.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top