這是我的源代碼,請教一下高手,為什麼經常會丟失這個cookie的值呢?
HttpCookie cookieUrl = new HttpCookie("User");
cookieUrl.HttpOnly = true;
cookieUrl.Expires = DateTime.Now.AddDays(1);
cookieUrl.Values["BackUrl"] = backUrl;
cookieUrl.Path = "/";
HttpContext.Current.Response.AppendCookie(cookieUrl);
這兩種方法都試了,都不能正常,開始正常,過幾分鐘就沒有了,有的時候用戶一登錄,馬上就提示未登錄,
HttpContext.Current.Response.Cookies["User"].HttpOnly = true ;
HttpContext.Current.Response.Cookies["User"].Expires = DateTime.Now.AddDays(1); //1天後過期
HttpContext.Current.Response.Cookies["User"].Values["BackUrl"] = backUrl;
HttpContext.Current.Response.Cookies["User"].Path = "/";