ASP.net Session Destroy if he closes the browser

前端 未结 8 1104
孤独总比滥情好
孤独总比滥情好 2021-01-17 03:34

I have an website. When the user is logged the session details will loaded. When the user logged out the session details will abandoned. (Log out by clicking the logout menu

8条回答
  •  鱼传尺愫
    2021-01-17 04:20

    try
        {
            Session["Admin"] = null;
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Session.Abandon();
            Session.Clear();                   
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Redirect("Dep_NewUserCreate.aspx");
    
    
        }
        catch(Exception ExLink)
        {
            Response.Redirect("Dep_NewUserCreate.aspx");
        }
    

提交回复
热议问题