471,315 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 1134
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


"accyboy1981" 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Darrin J Olson | last post: by
11 posts views Thread by Cecil Westerhof | last post: by
13 posts views Thread by David Hirschfeld | last post: by
2 posts views Thread by Donald Scott | last post: by
1 post views Thread by Fabio Cavassini | last post: by
2 posts views Thread by Big Daddy | last post: by
reply views Thread by rosydwin | last post: by

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.