Last post Aug 25, 2011 02:35 AM by Mamba Dai - MSFT
Aug 22, 2011 09:39 AM|skk1982|LINK
I have set up a session Like Session["id"]= some value; now on the same page i want to finish this session. what is the best way abondon, kill, remove etc thanks
Pls give me the syntax too. thanka
Aug 22, 2011 09:56 AM|komaldparekh|LINK
You can use
Session["Variable_name"] = null;
Session.abandon will remove all the session...
Aug 22, 2011 12:18 PM|konanki|LINK
Session["id"] = "testc";
Aug 24, 2011 01:41 AM|sirdneo|LINK
You have three options to remove/kill information from Session
1) Session.Remove("test"), it will delete only one variable
2) Session.Clear(), it will delete all the variables in session.
3) Session.Abandon, it will delete all the variables in session and also give new session ID to you.
Aug 24, 2011 02:05 AM|jassi_singh|LINK
Use the two lines to remove the session
Aug 24, 2011 03:23 AM|gopalanmani|LINK
you can try
Session["key"] = null;
Session.Clear stays in the same session.
Session.Clear will just clear the session data , the session is still alive
Session.Abandon dumps the current session and starts a new session.
Session_End will be fired and next request will fire Session_Start
Session ID will remain same in both cases, as long as the browser is not closed.
Aug 24, 2011 03:31 AM|morefays|LINK
If you want to declear and remove session on same page why you not try to use ViewState you dont need to remove Viewstate its automatically finished when you redirect to another page.
Aug 25, 2011 02:35 AM|Mamba Dai - MSFT|LINK
Once the Abandon method is called, the current session is no longer valid and a new session can be started, and the Session_OnEnd event is triggered.
Removes all keys and values from the session-state collection. The Session with the same key is still alive.
Deletes an item from the session-state collection.
More information please check this link: