Get Session to expire gracefully in ASP.NET

后端 未结 5 1931
南旧
南旧 2020-12-30 11:09

I need a way to tell ASP.NET \"Kill the current session and start over with a brand new one\" before/after a redirect to a page.

Here\'s what I\'m trying to do:

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 11:28

    The problem you are describing happens because asp.net is reusing the sessionid, if the sessionid still exists in the auth cookie when you call abandon() it will just reuse it, you need to explicitly create a new sessionid afaik something like:

     HttpCookie mycookie = new HttpCookie("ASP.NET_SessionId");
        mycookie.Expires = DateTime.Now.AddDays(-1);
        Response.Cookies.Add(mycookie);
    

提交回复
热议问题