473,651 Members | 2,663 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 2254
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
5152
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
29337
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
5223
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
4258
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
2152
by: Chris | last post by:
Can anybody tell me how to detect is the user has closed the browser Thank you
8
17370
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
4042
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
9049
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
5372
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
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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
7297
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
6158
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
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
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
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
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.