Aleks
asked on
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>
<%
Session.Contents.RemoveAll
%>
<script language=vbscript runat=server>
Session.Abandon()
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
:)
<%
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.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()
ASKER
Thanks !
ASKER