C# 清楚Cookies

//销毁Cookies中的数据
                    if (Request.Cookies["Ticket"] != null)
                    {
                        HttpCookie mycookie;
                        mycookie = Request.Cookies["Ticket"];
                        TimeSpan ts = new TimeSpan(0, 0, 0, 0);//时间跨度 
                        mycookie.Expires = DateTime.Now.Add(ts);//立即过期 
                        Response.Cookies.Remove("Ticket");//清除 
                        Response.Cookies.Add(mycookie);//写入立即过期的
                        Response.Cookies["Ticket"].Expires = DateTime.Now.AddDays(-1);
                    }

                 
           
                    Response.Cookies["AccountId"].Expires = DateTime.Now;
                    Response.Cookies["LoginName"].Expires = DateTime.Now;
                    Response.Cookies["Password"].Expires = DateTime.Now;
                    Response.Cookies["Email"].Expires = DateTime.Now;
                    Response.Cookies["LoginMobileNum"].Expires = DateTime.Now;
                    Response.Cookies["SubSiteLoginName"].Expires = DateTime.Now;
                    Response.Cookies["SubSitePassword"].Expires = DateTime.Now;

 

你可能感兴趣的:(C# 清楚Cookies)