C# 这是一些制作cookie的代码,你能告诉我如何取消制作吗?

C# 这是一些制作cookie的代码,你能告诉我如何取消制作吗?,c#,cookies,C#,Cookies,现在,当用户单击注销以销毁cookie时,我将在我的web应用程序中执行什么代码 注意:我已经尝试过这个方法,不管有没有注释行,它都不起作用: System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower(); System.Web.Http

现在,当用户单击注销以销毁cookie时,我将在我的web应用程序中执行什么代码

注意:我已经尝试过这个方法,不管有没有注释行,它都不起作用:

System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Value = tokenID.ToString();
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Path = "~/";
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(7);

我要做的是再次设置它,使用一个空白值和一个过去的到期日期:

    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Value = tokenID.ToString();
    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Path = "~/";
    System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(-1);

我要做的是再次设置它,使用一个空白值和一个过去的到期日期:

    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Value = tokenID.ToString();
    //System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Path = "~/";
    System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(-1);

通过设置cookie的过期时间使其过期

var context = System.Web.HttpContext.Current; 

context.Response.Cookies["ssocookies"].Domain = context.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
context.Response.Cookies["ssocookies"].Value = "";
context.Response.Cookies["ssocookies"].Path = "~/";
context.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(-1);

通过设置cookie的过期时间使其过期

var context = System.Web.HttpContext.Current; 

context.Response.Cookies["ssocookies"].Domain = context.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
context.Response.Cookies["ssocookies"].Value = "";
context.Response.Cookies["ssocookies"].Path = "~/";
context.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(-1);

FormsAuthentication.SignOut的方法执行以下操作:

System.Web.HttpContext.Current.Response.Cookies.Remove("ssocookies");

在任何情况下,使用类似于检查http通信量的方法都应该可以为您提供有关发生了什么事情的线索。

用于身份验证.SignOut的方法类似于:

System.Web.HttpContext.Current.Response.Cookies.Remove("ssocookies");

在任何情况下,使用类似于检查http通信量的内容都应该能为您提供一条关于发生了什么的线索。

System.Web.HttpContext.Current.Response.Cookies[“ssocookies”].Value=“Ohai!我给您制作了一个cookie,但我创建了它”原来最初的代码根本没有正确创建cookie…System.Web.HttpContext.Current.Response.Cookies[“ssocookies”]。Value=“O hai!我为您创建了一个cookie,但我创建了它”原来最初的代码根本没有正确创建cookie…它应该可以工作,我会检查浏览器实际上是如何存储cookie的。检查它是否在过程中被损坏。它应该可以工作,我会检查浏览器是如何存储cookie的。检查一路上它没有被弄坏。