cookie赋值问题

2024-12-26 23:14:00
推荐回答(2个)
回答1:

你怎么赋值的呢是?
public static void WriteCookie(string strName, string strValue, int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
cookie.Value = strValue;
cookie.Expires = DateTime.Now.AddMinutes((double)expires);
HttpContext.Current.Response.AppendCookie(cookie);
}

回答2:

在page_load中 写 Response.Cache.SetCacheability(HttpCacheability.NoCache);清除缓存