20140826_cookies&Session操作
2014-08-26 08:54 sunny_fan 阅读(140) 评论(0) 收藏 举报HttpCookie cookie = HttpContext.Current.Request.Cookies["__shareuser"] ?? new HttpCookie("__shareuser");
//检查是否存在 __shareuser Cookie如果不存在 ,新增一个
cookie.Value = (userInfo.Id + Key + DateTime.Now.AddDays(1)).Encryption();
//将Id,Key,以前失效时间加密,做为Cookie的值
cookie.Expires = DateTime.Now.AddYears(1);
//失效时间为:当前日期+1年
HttpContext.Current.Response.AppendCookie(cookie);
//添加Cookie
HttpContext.Current.Session["__shareuser"] = userInfo.Id;
Session赋值
浙公网安备 33010602011771号