By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

Detect moment when user closed session

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"NWx" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

Nov 18 '05 #2

P: n/a
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

"Michael Ramey" <raterus@localhost> wrote in message
news:eu**************@TK2MSFTNGP11.phx.gbl...
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

"NWx" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.