Session.Abandon();
Session.Clear();
Session["user"]=null

i m trying to clear a Session but these methods are not working..how can i clear this Session plz help me.. thnxx

In order to completely erase it from memory: Session.remove("YourSessionName").

In order to clear its data if it's a basic string: session("YourSessionName") = ""

In order to completely erase it from memory: Session.remove("YourSessionName").

In order to clear its data if it's a basic string: session("YourSessionName") = ""

This is also not working

Don't use #2 and #3 line statements. Use Session.Abandon() method.

Don't use #2 and #3 line statements. Use Session.Abandon() method.

this is also not working...

this is my code

protected void Page_Load(object sender, EventArgs e)
    {
   if (Session["user"] != null)
        {
//some codes
            
        }
        else
        {

            Response.Redirect("Default.aspx");
        }
}



protected void Button1_Click2(object sender, EventArgs e)
    {

     
      
        Session.Abandon();
        Response.Redirect("Default.aspx");
    }

try to kill but still it is alive....

I guess you want to disabled the cache.

Write following line in page_load handler.

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Session.Remove("User");
hope so it works

To remove all Session variable use

Session.Removeall();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.