码迷,mamicode.com
首页 > 其他好文 > 详细

cookies&Session操作

时间:2014-08-26 09:39:55      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   amp   时间   sp   new   on   ad   

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赋值

cookies&Session操作

标签:http   io   ar   amp   时间   sp   new   on   ad   

原文地址:http://www.cnblogs.com/fanfh/p/3936435.html

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