Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove specific session in asp.net?

I am facing a problem. I have created two sessions:

  1. Session["userid"] = UserTbl.userid;
  2. Session["userType"] = UserTbl.type;

I know how to remove sessions using Session.clear(). I want to remove the session "userType".

How do I remove a specific session?

like image 677
Chintan Avatar asked Jan 23 '12 12:01

Chintan


People also ask

How do I delete a session?

A PHP session can be destroyed by session_destroy() function. This function does not need any argument and a single call can destroy all the session variables. If you want to destroy a single session variable then you can use unset() function to unset a session variable.

Which method is used to remove session in asp net?

The ASP Session. Abandon Method is used to destroy a session of the user. Generally , It destroys the object which are stored in the Session object. If we do not call the Abandon method explicitly, the server destroys these objects when the session times out.

How do you delete a session in Visual Basic?

You can set session variables in usual way using string as a key e.g. Session["Key"] = obj; To destroy the object in Session set it to null. Session["Key"] = null. you can clear the user session through the session.

How do you close a session in C#?

You can use Session. Abandon(); or Session. Clear(); 1.


2 Answers

There is nothing like session container , so you can set it as null

but rather you can set individual session element as null or ""

like Session["userid"] = null;

like image 45
Milan Mendpara Avatar answered Oct 01 '22 13:10

Milan Mendpara


Session.Remove("name of your session here"); 
like image 181
gabsferreira Avatar answered Oct 01 '22 13:10

gabsferreira