473,372 Members | 883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

How can I make sure that Session_End is called when the user closes the browser?

Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not fired.

how can I call explicity protected void Session_End(Object sender, EventArgs
e)
when the user closes the browser window?

possible at all?

TA
Nov 19 '05 #1
6 2084
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?


Not possible. You're working with a connectionless architecture. The
server has no knowledge of when the user closes their browser.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #2
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA


The session does not end when the user closes the browser, but (default)
20 minutes after the last request to the site. (So if he was busy for 30 minutes
reading a single page, the session would have ended).

There is no (reliable) way to detect that the user has closed the browser,
navigated away from the site, or lost his internet connection.

Hans Kesting
Nov 19 '05 #3
KMA
which is why ebanking software has a "log out" button, so it can call
session abort.

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:eN**************@TK2MSFTNGP14.phx.gbl...
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA
The session does not end when the user closes the browser, but (default)
20 minutes after the last request to the site. (So if he was busy for 30

minutes reading a single page, the session would have ended).

There is no (reliable) way to detect that the user has closed the browser,
navigated away from the site, or lost his internet connection.

Hans Kesting

Nov 19 '05 #4
wow gettting very interesting!
How about catching it in client side using Javascript and something and
passing it to server somehow?
not possible at all?
"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not fired.

how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA

Nov 19 '05 #5
Annie wrote:
wow gettting very interesting!
How about catching it in client side using Javascript and something
and passing it to server somehow?
not possible at all?


Sessions use a sliding expiration. That means that as soon as you "pass it
on to the server", you reset your Session expiration, thereby delaying the
execution of Session_End, not expediting it.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #6
Annie wrote:
wow gettting very interesting!
How about catching it in client side using Javascript and something
and passing it to server somehow?
not possible at all?


Hit Send too soon. :)

Of course you could have your browser call a page that calls
Session.Abandon, but you have to remember that there is no way to hook a
client side event ONLY when the browser is closed. It would be impossible
(as far as I can think right off this early in the AM) to detect the browser
closing correctly.

One more thing to add. Session_End is indeterminate. Even if you call
Session.Abandon, you cannot guarantee when Session_End will get called.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Sibel | last post by:
Hey guys I have a user tracking setup to track users. What it does is once a user hits my site it sends me an email telling me some info and once a user clicks the logout button it sends a second...
5
by: JezB | last post by:
Why is my Session_End event in global.asax never firing ? I've tried fiddling with the timeouts but still nothing. Ideally I want to do some processing whenever someone leaves my web application...
3
by: MattB | last post by:
Hi. I have a couple of questions regarding the Session_End event. I have some clean-up code in this event and it does fire when the session times out, which is good. I also want to have this (or...
1
by: Timo | last post by:
A few questions relating to sessions ending. 1. What happens to the session when a user closes the browser? Does the session remain alive until it times out? 2. In the Session_End...
2
by: sundar_s1210 | last post by:
I am doing a Shop Cart application In my asp.net application, i want to delete some records from database when user closes the browser without purchasing the product which is added to shop cart....
0
by: rsford31 | last post by:
I have an application where users are assigned roles: control (can edi items, delete items add items), update (can update items) and read (ca only read content). When the user logs into the web...
7
by: Bruno | last post by:
We are attempting to automatically log users off from the Session_End event in global.asax and set some values on session_start. It is not a critical task, more of a housekeeping task so that we...
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
5
by: Ron J | last post by:
I would like to keep track of users when they are 'on'. On Session_Start I can write a DB record about them, but there does not seem to be session variable information during the Session_end event...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.