码迷,mamicode.com
首页 > Windows程序 > 详细

C# 清楚Cookies

时间:2016-02-03 10:49:14      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

//销毁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

标签:

原文地址:http://www.cnblogs.com/foreverfendou/p/5179100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!