Code to abandon session variables

Which of the codes below is better and what would the difference be ?

<%
 Session.Contents.RemoveAll()
 %>

<script language=vbscript runat=server>
Session.Abandon()
</script>
LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
essentially they do the same thing, except Session.Abandon includes Session.RemoveAll and also deletes the session id created for the session. It will also create a new session ID.

To truly delete the session, use Session.Abandon()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Thanks !
0
AleksAuthor Commented:
:)
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
<%
Session.Contents.RemoveAll()
Session.Abandon()
%>

The Contents.RemoveAll clears the contents stored in the session https://msdn.microsoft.com/en-us/library/ms524866(v=vs.90).aspx while Abandon destroys the objects https://msdn.microsoft.com/en-us/library/ms524310(v=vs.90).aspx  Note that if at the top of the page you use Abandon, you can still access sessions on the rest of the page.

If you are using this for a logout I would do something like

session("user_name") = ""
session("user_auth")=""
Session.Contents.RemoveAll()
Session.Abandon()

Open in new window

0
AleksAuthor Commented:
Thanks !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.