M
Marco Rispoli
I am using this function to write a cookie:
private static void SaveCookie(string CookieName, string CookieValue, bool
Persistent)
{
HttpContext.Current.Response.Cookies[CookieName].Value = CookieValue;
HttpContext.Current.Response.Cookies[CookieName].Path = "/";
HttpContext.Current.Response.Cookies[CookieName].Domain =
ConfigurationSettings.AppSettings["cookie_domain"].ToString();
if (Persistent) {HttpContext.Current.Response.Cookies [CookieName].Expires
= DateTime.Now.AddMonths(12);}
}
The cookie gets written correctly except that if I pass false to Persistent
(and Expires doesn't get set, I stepped through the code, I am sure of
that), the cookie is still persistent.(if I close the browser and re-open it
the cookie is still there).
I had similar code in traditional ASP and it was working fine. Is there a
step I am missing?
The default value of the Expires property appears to be {1/1/1}
PS: I am not using formsauthentication and I don't plan to do it.
Thanks!
private static void SaveCookie(string CookieName, string CookieValue, bool
Persistent)
{
HttpContext.Current.Response.Cookies[CookieName].Value = CookieValue;
HttpContext.Current.Response.Cookies[CookieName].Path = "/";
HttpContext.Current.Response.Cookies[CookieName].Domain =
ConfigurationSettings.AppSettings["cookie_domain"].ToString();
if (Persistent) {HttpContext.Current.Response.Cookies [CookieName].Expires
= DateTime.Now.AddMonths(12);}
}
The cookie gets written correctly except that if I pass false to Persistent
(and Expires doesn't get set, I stepped through the code, I am sure of
that), the cookie is still persistent.(if I close the browser and re-open it
the cookie is still there).
I had similar code in traditional ASP and it was working fine. Is there a
step I am missing?
The default value of the Expires property appears to be {1/1/1}
PS: I am not using formsauthentication and I don't plan to do it.
Thanks!