By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,340 Members | 1,370 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,340 IT Pros & Developers. It's quick & easy.

Close User Session

P: n/a
How can i configure my application for closing the session ? How can i use
the session end for closing the session ?
Mar 14 '07 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Session end is only the event fired when a session is ended. To end the
user's session you would use Session.Abandon() I believe. It will
automatically close the session after 20 minutes of inactivity anyways, and
unload the application itself after the last session is closed.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Laurahn" <le*****@newsgroups.nospamwrote in message
news:e1**************@TK2MSFTNGP03.phx.gbl...
How can i configure my application for closing the session ? How can i use
the session end for closing the session ?

Mar 14 '07 #2

P: n/a
On Mar 14, 11:17 pm, "Laurahn" <leme...@newsgroups.nospamwrote:
How can i configure my application for closing the session ? How can i use
the session end for closing the session ?
Configure a timeout or call Session.Abandon()

Mar 14 '07 #3

P: n/a
Thanks Mark.

But, i want to know what code I have to put into my app for that hapends.

Can i use a button?

i've read about put some code on Global.asax
Mar 14 '07 #4

P: n/a
How i Configure a timeout?

Where have I to call Session.Abandon()?
Mar 14 '07 #5

P: n/a
"Laurahn" <le*****@newsgroups.nospamwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
But, i want to know what code I have to put into my app for that hapends.

Can i use a button?

i've read about put some code on Global.asax
In Global.asax, you have an event called Session_End - this is the event
which fires (so long as your Session is InProc) when the Session ends.

Under normal circumstances, the Session ends for two reasons:

1) it has timed out automatically, by default after 20 minutes of
inactivity, though this figure can be changed

2) it has been ended explicitly ("torn down", to use the jargon)

You may be familiar with logging out of your on-line banking application by
clicking a "Logout" button or whatever - it is the code behind such a button
where you would place the Session.Abandon() code.
Mar 14 '07 #6

P: n/a
Make a button on your web page. Give it text of "Log out". In its
server-side click event handler, simply write: Session.Abandon()

And/Or in your Web.Config file, find the section that is already there about
the session timeout and change the time from 20 minutes to something else.

"Laurahn" <le*****@newsgroups.nospamwrote in message
news:u$****************@TK2MSFTNGP06.phx.gbl...
How i Configure a timeout?

Where have I to call Session.Abandon()?


Mar 15 '07 #7

P: n/a
You response doesn't really address the question. The Session_End event
handler is of no use when you are trying to end the session, only after (or
as) the session has ended.

I have been working with sessions for many, many years and you are the first
person to use the "torn down" jargon you speak of that I've ever heard.
It's not a good idea to introduce jargon that is not widely used.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uh**************@TK2MSFTNGP03.phx.gbl...
"Laurahn" <le*****@newsgroups.nospamwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
>But, i want to know what code I have to put into my app for that hapends.

Can i use a button?

i've read about put some code on Global.asax

In Global.asax, you have an event called Session_End - this is the event
which fires (so long as your Session is InProc) when the Session ends.

Under normal circumstances, the Session ends for two reasons:

1) it has timed out automatically, by default after 20 minutes of
inactivity, though this figure can be changed

2) it has been ended explicitly ("torn down", to use the jargon)

You may be familiar with logging out of your on-line banking application
by clicking a "Logout" button or whatever - it is the code behind such a
button where you would place the Session.Abandon() code.

Mar 15 '07 #8

P: n/a
I don't believe the application is unloaded after the last session is
unloaded. I belive the application sits idle until it crashes or is taken
off-line, but I don't believe it just ends itself.
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:uQ**************@TK2MSFTNGP05.phx.gbl...
Session end is only the event fired when a session is ended. To end the
user's session you would use Session.Abandon() I believe. It will
automatically close the session after 20 minutes of inactivity anyways,
and unload the application itself after the last session is closed.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Laurahn" <le*****@newsgroups.nospamwrote in message
news:e1**************@TK2MSFTNGP03.phx.gbl...
>How can i configure my application for closing the session ? How can i
use the session end for closing the session ?


Mar 15 '07 #9

P: n/a
"Scott M." <s-***@nospam.nospamwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
Make a button on your web page. Give it text of "Log out". In its
server-side click event handler, simply write: Session.Abandon()
Wish I'd thought of that... ;-)
Mar 15 '07 #10

P: n/a
You did, but apparently this person wants us to come over and type it in for
him/her.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Scott M." <s-***@nospam.nospamwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
>Make a button on your web page. Give it text of "Log out". In its
server-side click event handler, simply write: Session.Abandon()

Wish I'd thought of that... ;-)

Mar 15 '07 #11

P: n/a
Hi Laurahn,

Regarding on the "close user session", I'd like to confirm the exact goal
you want to achieve. Generally, for ASP.NET session state you have the
following options to configure or manage it at design-time or runtime:

1. turn on or turn off it in web.config <sessionStateelement.

#<sessionStateElement
http://msdn2.microsoft.com/en-us/lib...z9(VS.71).aspx

2. You can also set "timeout" value in the above element which control the
timespan after which the runtime will dispose a certain idle sessionstate

3. You can control whether a certain ASPX page can access sessionstate
through the "@Page" directive's "EnableSessionState" attribute:

#@ Page
http://msdn2.microsoft.com/en-us/lib...4a(VS.71).aspx

4. As other members have mentioned, at runtime, in code, you can explicitly
call "Session.Abandon" method in page to terminate the current session:

#HttpSessionState.Abandon Method
http://msdn2.microsoft.com/en-au/lib...te.httpsession
state.abandon.aspx

If you wonder when to call it, I think it depend on your application's code
logic, you can put the call into a page event where you want to end a
session and clear all the data in it. If you only want to remove data, but
do not want to terminate the session(and start a new one), you can simply
use the "Session.RemoveAll" or "Session.Clear" to empty the sessionstate
collectiono.

In addition, here is a popular ASP.NET session FAQ article which mentioned
many common tips about using sessionstate:
#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Mar 15 '07 #12

P: n/a
To Empty Session state there are so many ways depends on requirements:
i am taking some cases:

1. Suppose u want to End the Particular Session state

Session["KEY"] = null;
Session["abc"] = null;
OR
Session["abc"] = "";

2. Suppose u want to End all the Session's in application

Session.Abandon();
OR
Session.Clear();

So here u go.......
Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 15 '07 #13

P: n/a
To Empty Session state there are so many ways depends on requirements:
i am taking some cases:

1. Suppose u want to End the Particular Session state

Session["KEY"] = null;
Session["abc"] = null;
OR
Session["abc"] = "";

2. Suppose u want to End all the Session's in application

Session.Abandon();
OR
Session.Clear();

So here u go.......
Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 15 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.