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;

 

posted @ 2016-02-03 10:17  秋风过、枯叶落  阅读(723)  评论(0编辑  收藏  举报