473,574 Members | 7,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ending a Session in a Web Application

Hi,

I'm relatively new to C# and am having some problems with sessions. I
have a web application where the user logs in to add comments to a
database. Once the user is logged in this opens the sessions. What I
want to do is to end the session when the user either closes the web
page or navigates to another page. I have tried to do this with the
onunload function but without success. Any help would be appreciated.

Thanks

Simon

Feb 15 '06 #1
1 1242
Simon,
The only way I know to imperatively close a Session is to use the
Session.Abandon method. Otherwise, the Session_End handler in Global will
fire on its own at the server after the sliding timeout period has expired
with no intervening requests, regardless of whether the user is still there
or has gone to lunch.

As far as gaining some level of control where the user leaves the page, try
having a look at the onbeforeunload event.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"accyboy198 1" wrote:
Hi,

I'm relatively new to C# and am having some problems with sessions. I
have a web application where the user logs in to add comments to a
database. Once the user is logged in this opens the sessions. What I
want to do is to end the session when the user either closes the web
page or navigates to another page. I have tried to do this with the
onunload function but without success. Any help would be appreciated.

Thanks

Simon

Feb 15 '06 #2

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

Similar topics

14
4047
by: Darrin J Olson | last post by:
I am trying to end a session for a site without having to completely close the browser to end it. When I access the site and log in it works fine. If I log out and in with a different account without closing the browser, I get the first session's information. Also, if a open another browser and log in with a different account I get the...
11
1392
by: Cecil Westerhof | last post by:
Is it possible to end a session a from another session b, if I know the SessionID from a?
13
1469
by: David Hirschfeld | last post by:
I have built an asp.net application that runs in explorer and does a bunch of screen scraping and posting to various websites using httpWebRequest and httpWebResponse. My application loops through various URLs, performing various jobs on specified websites. When I break the application in debug mode, all associated processes stop...
7
1265
by: Shanli RICHEZ | last post by:
I'm using ASP.NET and quite a lot of object in memory instead of a database. The question is that I tried to save the data, serialize them in a XML file to save them when the application is ending. event : Application_End in Global.asax. But the object are not accesible from there so I can't save them. Any idea ???
2
1921
by: Donald Scott | last post by:
We are having a problem with sessions ending sooner then they should. We have a two server web garden, both servers have identical machine keys. I'm storing session state in Sql Server. Sessions expire in 20 minutes even though I have changed the settings in the web.config, for both the forms authentication as well as the session. I have...
1
1142
by: Fabio Cavassini | last post by:
I've got the following configuration in Web.config <authentication mode="Forms"> <forms name=".ASPXCOOKIE" loginUrl="sigin.aspx" protection="All" timeout="30" path="/"> </forms> </authentication> <authorization> <deny users="?" /> </authorization>
2
1206
by: Big Daddy | last post by:
I have an ASP.NET application where the user will be right in the middle of doing something and the sessions ends and then it blows up because I have stored some things in the Session hashtable. I know it's not ending because of the usual culprits (timeout, web.config file changing, anti-virus software scanning the dll, etc.). So I am...
8
1856
by: Christian Blackburn | last post by:
Hi Gang, I would like to have my application retain sessions even after the user closes their browser window, up unil the time the session is supposed to time out. Right now if the user closes IE their session is re-created. Is there any way around this? Thanks, Christian Blackburn
6
5146
by: Ken Varn | last post by:
When I am running my ASP.NET 2.0 application using VS.NET 2005 ASP.NET Development Server, the session state seems to be getting lost at various times without warning. I am not sure why this is happening. It is not related to timeout because it occurs way before the default of 20 session timeout setting. One thing that I did notice that...
0
7817
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...
0
8081
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. ...
0
8258
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...
0
8119
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5635
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...
0
5322
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3759
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...
1
1359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1082
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...

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.