我试图将一些数据保存到cookie中,但在回发后如果我在pageload中检查cookie的值,则该值始终为null
这就是我设置和获取cookie的方式
private static string GetCookie(string name)
{
return HttpContext.Current.Response != null ? HttpContext.Current.Response.Cookies[name].Value : string.Empty;
}
private static void SetCookie(string name, string value)
{
HttpContext.Current.Response.Cookies[name].Value = value;
HttpContext.Current.Response.Cookies[name].Expires = DateTime.Now.AddDays(ExpireTimeInDays);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5290 次 |
| 最近记录: |