How to Kill A Session or Session ID (ASP.NET/C#)

前端 未结 9 1302
礼貌的吻别
礼貌的吻别 2020-11-30 04:09

How can I destroy a session (Session[\"Name\"]) when the user clicks the logout button?

I\'m looking through the ASP.NET API Reference on MSDN and it doesn\'t seem t

9条回答
  •  春和景丽
    2020-11-30 04:37

    It is also a good idea to instruct the client browser to clear session id cookie value.

    Session.Clear();
    Session.Abandon();
    Response.Cookies["ASP.NET_SessionId"].Value = string.Empty;
    Response.Cookies["ASP.NET_SessionId"].Expires = DateTime.Now.AddMonths(-10);
    

提交回复
热议问题