Often asked by users, how to kill sessions? how to remove sessions?, what is the difference between Session.Clear(), Session.Abandon() and Session.RemoveAll()? which is the best?. etc.
So, here is the full explanation of all methods.
Session.Clear and Session.RemoveAll is like a twin, Both will immediately remove all stored values from session, but the session object still in the memory. In this, Session_OnEnd will not execute/hit.
Session.Abandon in actual it’s not clear the values immediately, it just indicates the session to be abandoned at the end of the current request. We can continue to read the values for the rest of the request. If we write to the session later in the request, the new value will be dropped at the end of the request with no indication. Session_OnEnd executes at the end of the request.
- To clear Session
- To remove Session
- To abandon Session.
As we can see, In Clear and RemoveAll/Remove method Session immediately remove values from request session wherein Abandon Session values is still in session till the end of a request.
If you are looking to store values in the session, you can find here.