1

I have HttpContext.Current.Session["CurrentUser"] = user; somewhere in my code and in the logout I have this

public ActionResult LogOff()
{
           AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            return RedirectToAction("Index", "Home");
}

I just want to make sure that HttpContext.Current.Session is also destoyed when I logoff. If not then how do it destroy it?

Heero Yuy
  • 614
  • 9
  • 24
  • [MSDN](https://msdn.microsoft.com/en-us/library/ms178581.aspx) suggest to call session `Abandon()` after logout. Refer the third note in the link. – Siva Gopal Feb 18 '17 at 03:14

1 Answers1

1

I think the server will hold on to Session data for 20 minutes by default, unless you do something explicit.

But you can clear particular Session variables on logout or abandon the session.

See here for more info: What is the difference between Session.Abandon() and Session.Clear()

Community
  • 1
  • 1
Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73