c#清除cookie的方式

时间:2014-11-24 11:56:39   收藏:0   阅读:255
HttpCookie cok = Request.Cookies["institutionAccount"];
                if (cok != null)
                {
                    cok.Values.Remove(ConstVariables.CurrentInstitutionAccountSessionKey);//移除键值为userid的值
                    TimeSpan ts = new TimeSpan(-1, 0, 0, 0);
                    cok.Expires = DateTime.Now.Add(ts);//删除整个Cookie,只要把过期时间设置为现在
                    Response.AppendCookie(cok);
                }
评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!