日期:2014-05-17 浏览次数:20399 次
HttpCookie httpCookie = null;
string name = "UserInfo";
if (context.Request.Cookies[name] == null)
{
httpCookie = new HttpCookie(name);
httpCookie.Path = "/";
if (context.Request["autoLogin"] == "checked") httpCookie.Expires = DateTime.MaxValue;
else httpCookie.Expires = DateTime.Now.AddHours(1);
httpCookie.Value = context.Server.UrlEncode(myuser.CombineUserInfo());
context.Response.Cookies.Add(httpCookie);
}
else
{
try
{
httpCookie = context.Request.Cookies[name];
httpCookie.Value = context.Server.UrlEncode(myuser.CombineUserInfo());
if (context.Request["autoLogin"] == "checked") httpCookie.Expires = DateTime.MaxValue;
else httpCookie.Expires = DateTime.Now.AddHours(1);
httpCookie.Path = "/";
context.Response.Cookies.Add(httpCookie);