Loss of C#.net cookie regular

This is my source code, consult a master, why is often missing the cookie value?


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);

These two methods are tried, are not normal, normal, a few minutes is not, sometimes the user login, immediately suggested that unknown,

HttpContext.Current.Response.Cookies["User"].HttpOnly = true ;
HttpContext.Current.Response.Cookies["User"].Expires = DateTime.Now.AddDays(1); //1 days overdue
HttpContext.Current.Response.Cookies["User"].Values["BackUrl"] = backUrl;
HttpContext.Current.Response.Cookies["User"].Path = "/";

Please master advice, thank you!

Posted by Josephine at December 13, 2013 - 10:28 PM