What is the best way to end session?

H

Hugo Flores

Hi all,

I noticed that there are three methods that can remove session
variables
Session.Clear()
Session.RemoveAll()
Session.Abandon()

Now my question as is stated on the subject, what is the best way to
end a session?
I know that the name itself is telling me that Sessin.Abandon() should
be the methond called when ending a session, but if the other two
methods clear or remove all the variables, isn't that the same, since
if I want to go to a page that requires a session variable it just
won't have it?
Actually I found using either RemoveAll or Clear, better than Abandon,
since the Remarks on the Abandon method on MSDN already state that you
can still access session variables after calling the method.
Could anybody explain the difference among these methods?
 
M

Marina

The first 2 only remove session variables you have stored so far. The
session itself is still alive.

Session.Abandon is the only one of those that actually kills the session.
 
S

Siva M

Clear() and RemoveAll() perform the same thing: remove the session variables
but keep the current session in memory. Whereas, Abandon() ends the current
session.

Hi all,

I noticed that there are three methods that can remove session
variables
Session.Clear()
Session.RemoveAll()
Session.Abandon()

Now my question as is stated on the subject, what is the best way to
end a session?
I know that the name itself is telling me that Sessin.Abandon() should
be the methond called when ending a session, but if the other two
methods clear or remove all the variables, isn't that the same, since
if I want to go to a page that requires a session variable it just
won't have it?
Actually I found using either RemoveAll or Clear, better than Abandon,
since the Remarks on the Abandon method on MSDN already state that you
can still access session variables after calling the method.
Could anybody explain the difference among these methods?
 
H

Hugo Flores

Hi Marina,

Thanks for the clarification.
Do you know the difference betweeen RemoveAll and Clear?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top