I have a web app that is a mixture of ASP and ASP.NET pages. Largely the
only data passed between them is via the querystring, or by reading from a
database. However there is a requirement for one part to communicate via a
cookie. (Please dont ask me to go into why, I don't have time).
In my ASP page, I created a cookie and put a value in it:
Response.Cookies("MyCookieName") = "OriginalValue"
Response.Cookies("MyCookieName").Expires = CDate("31/12/2030")
Response.Cookies("MyCookieName").Path = "/"
That works great. The cookie appears in the Temporary Files folder on disk,
with the distant expiry date as expected. Furthermore I look inside the
cookie using Notepad, and it shows the "OriginalValue" that I put in.
Now I want to read that same cookie from my ASP.NET page, using:
Dim CookieVal as String = Request.Cookies.Item("MyCookieName").Value
....which seems to work perfectly OK. It returns "OriginalValue" that I put
in there using ASP.
Now, the problem is that I cannot seem to *update* the cookie via my ASP.NET
Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
c.Value = "MyNewValue"
After running the above code, I take a look inside the cookie, but the
"OriginalValue" remains. No errors occurred, it did not crash, but didn't
work either. I cannot understand why.
What am I missing?
PS. replies cc'd via email appreciated as this is quite urgent
Re: cookie troubles
> Now, the problem is that I cannot seem to *update* the cookie via my
> Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
> c.Value = "MyNewValue"
IIRC, you should add : Response.Cookies.Add(c);
- - -
|All times are GMT. The time now is 07:34 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.