我試圖保持一些數據Cookie,但回發後,如果我檢查在頁面加載的值總是空的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);
}
從你在哪裏調用這些方法?從ASPX頁面中的特定事件?你可以在你的頁面或處理程序中顯示代碼來調用這些代碼嗎? – Eilon 2010-08-12 18:14:59
我認爲你需要從請求中獲取cookie。 – dotjoe 2010-08-12 18:16:48