473,836 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect moment when user closed session

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
2 2265
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.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.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
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@localh ost> wrote in message
news:eu******** ******@TK2MSFTN GP11.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.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5176
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different documents (txt, MS Office files, pdf, pictures,…) from inside my app. It must start the file with the adequate external program (Notepad, MS Office programs, Acrobat Reader, some Picture viewer,... ) and be notified when this programs closes the...
4
29367
by: sm mehta | last post by:
Hi, I have a web Application that must be licensed. When Customer buys 2 licensees for my application they can only have 2 copies open at a time. What I am doing right now is, I am storing No. Of License in the SQL Table, and on each connection i would reduce 1 license from the DB. My problem is when user closes IE Browser, I want to capture this event and return the license to the DB. How do I know when user closed the browser? I have...
6
5245
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
3
4269
by: Lord2702 | last post by:
Sat. Oct. 30, 2004 3:25 PM PT I want to detect, if user has close the browser, (after logging to my site), that user has closed the browser. How to achieve it ? I want to know this close action on my server-side code. Because if he logout by clicking on Logout/ Sign-Off button it simple to get the message. Although, this is very similar to the first above. Also, if user takes any action on client-side or browser side how will I detect...
7
2169
by: Chris | last post by:
Can anybody tell me how to detect is the user has closed the browser Thank you
8
17390
by: Luke Matuszewski | last post by:
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg. function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can detect the close of the browser window */ } if(window.event) { /* maybe via analyse of window.event object i can detect the close of the browser window */
4
4062
by: Dst | last post by:
This is what i'm trying to do: I'm porting a windows app to a web app. I have a webform which will edit some data stored in a database. The data needs to be locked in the database, while editing. On first page load: Create a custom rowlock object and store it in viewstate. When user clicks on edit, retrieve the viewstate object and lock the row in the database.
18
9068
by: sebastian | last post by:
Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found that sometimes the old session data remained even after the user left the site and returned. Just had an idea, though. Perhaps I could access the users Referrer header?
36
5415
by: Don | last post by:
I wrote an app that alerts a user who attempts to open a file that the file is currently in use. It works fine except when the file is opened by Notepad. If a text file is opened, most computers are configured to use Notepad to open the file by default and if they are configured to use Notepad by default I want it to remain that way rather than retrieve the text into my app or force the user to use another app to read the file. I'm...
0
9671
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10846
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10594
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4458
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.