日期:2014-05-17 浏览次数:20704 次
//以一维的形式记录Cookie Response.Cookies["userid"].Value = user.Id.ToString(); //Cookie失效期限为一个月 Response.Cookies["userid"].Expires = DateTime.Now.AddDays(30); //设置域名 Response.Cookies["userid"].Domain = "xxx.com"; //获取Cookie Request.Cookie["userid"].Value //以二维的形式记录Cookie HttpCookie cookie = new HttpCookie("member"); cookie.Values.Add("memberid", user.Id.ToString()); cookie.Values.Add("membername", user.Membername); //Cookie失效期限为一年 cookie.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(cookie); //获取Cookie Request.Cookie["member"]["memberid"].ToString()