首页 > 代码库 > Cookie与Session

Cookie与Session

设置cookie过期

cookie.Expires = DateTime.Now.AddDays(-1);

HttpContext.Current.Request.Cookies.Set(cookie);

HttpContext.Current.Response.Cookies.Set(cookie);

 

设置cookie的过期时间

  var day = AppSettingManager.Get("userCookieExpires");
cookie.Expires = DateTime.Now.AddDays(Convert.ToInt32(day));

 

 sessionState的过期时间

<sessionState mode="InProc" customProvider="DefaultSessionProvider" timeout="20"> 

Cookie与Session