Modifying cookies with subkey

ultraman

Centurion
Joined
Dec 31, 1969
Messages
138
Location
Quebec, Canada
Hi all !

According to this MSDN article, to modify an existing subkey in a cookie, you just do this :

Code:
Response.Cookies("userInfo")("lastVisit") = DateTime.Now.ToString
Response.Cookies("userInfo").Expires = DateTime.Now.AddDays(1)

The problem is.... it destroys all other subkeys. Actualy, it seems like it deletes the cookie and recreate a new one. So, is there an easy way to modify a subkey in a cookie or do I have to copy all values from the Request cookie inside the Response cookie before changing the Expires date ?
 
For those who might be interested, it was just a question of first getting the cookie from the Request object. After you get this, you modify the value and add this new cookie to the Response object.

Code:
Dim cookie As HttpCookie = Request.Cookies("MyPOS")
cookie("CliID") = strInfo(0)
cookie("CliName") = strInfo(1)
cookie("Address") = strInfo(2)
cookie.Expires = DateTime.Now.AddDays(365)
Response.Cookies.Add(cookie)
 
Back
Top