cookie读、写、删除

cookie读、写、删除 创建cookie var cookie = new HttpCookie("member"); cookie.Values.Add("memberName", name); cookie.Values.Add("memberType", type.ToString()); cookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookie); 读Cookie var cookie = Request.Cookies["member"]; if (cookie != null) { string name = cookie.Values["memberName"]; string type=cookie.Values["memberType"]; } 删除cookie var cookie = Request.Cookies["member"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); }
posted @ 2011-07-18 12:38  八神吻你  阅读(354)  评论(0编辑  收藏  举报