What is the difference between Session.Abandon() and Session.Clear() in ASP.Net?

Piyush picture Piyush · Jun 11, 2010 · Viewed 9.6k times · Source

What is the difference between Session.Abandon() and Session.Clear() in ASP.Net?

Answer

djdd87 picture djdd87 · Jun 11, 2010

Session.Abandon() will end the current session. Session_End will be fired and the next request will fire the Session_Start event.

Session.Clear will just clear the session data and the the session will remain alive.

Session ID will remain the same in both cases, as long as the browser is not closed.

In a nutshell:

Session.Abandon(); cancels the current Session.

Session.Clear(); clears all values from Session state.