What is the difference between destroying a session and removing its values? Can you please provide an example demonstrating this?
I searched for this question, but don't grasp total answer. Some answers are:
Session.Abandon()
destroys the sessionSession.Clear()
just removes all values
A friend told me this:
Clearing the session will not unset the session, it still exists with the same ID for the user but with the values simply cleared.
Abandon will destroy the session completely, meaning that you need to begin a new session before you can store any more values in the session for that user.
The below code works and doesn't throw any exceptions.
Session.Abandon();
Session["tempKey1"] = "tempValue1";
When you Abandon() a Session, you (or rather the user) will get a new SessionId
When I test Session, it doesn't makes any change when I Abandon the session.
I just find one difference:
session.Abandon()
raises Session_End
event