簡體   English   中英

注銷時,Asp.net在服務器上擺脫會話

[英]Asp.net get rid of session on server on logout

我遇到了asp.net的安全問題。 在注銷時,我想確保會話被銷毀,以便有人不能使用相同的sessionid和auth cookie並在那里編輯cookie,服務器仍然會響應會話。

FormsAuthentication.SignOut();
Session.Abandon();
Session.RemoveAll();
Session.Clear(); 

我嘗試過在不同的訂單中使用以下內容,但仍然沒有骰子。 如果我使用原始的sessionid和Auth cookie,我仍然可以登錄。 我希望服務器在我注銷時完全忘記該sessionid。 這甚至可能嗎?

如果您使用的是FormAuthentication,那么您可以使用

FormsAuthentication.SignOut();
Session.Abandon();

您還可以按如下方式使cookie過期

// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);

HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);

如果您使用的是表單身份驗證,則可能不會調用FormsAuth.SignOut();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM