I have a script that reads a form and puts some info into a cookie:
Dim oCookie as HttpCookie
oCookie = New HttpCookie("authInfo")
Select Case oResult
Case "No ClientID", "No Password", "No PracType", "No Encrypt", "CRC Mismatch"
oCookie.Values.Add("LoggedIn", "False")
oCookie.Values.Add("OnSupport", "False")
Case "Client Can Update"
oCookie.Values.Add("LoggedIn", "True")
oCookie.Values.Add("OnSupport", "True")
Case "Client Cannot Update"
oCookie.Values.Add("LoggedIn", "True")
oCookie.Values.Add("OnSupport", "False")
End Select
oCookie.Expires = DateTime.Now.AddHours(2)
HttpContext.Current.Response.Cookies.Add(oCookie)
HttpContext.Current.Response.Redirect("default.aspx")
The time is properly set right before it redirects, but when I try to print out that value this way (I have also tried Dim oCol as HttpCookieCollection = Request.Cookies
, but I get the same result):
Response.Output.WriteLine(Request.Cookies("authInfo").Expires.ToString)
The time is always reset "01/01/0001 12:00:00 AM"
. Am I missing something that prevents the cookie from holding its Expires
value?