Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all !

 

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

 

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 ?

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

Posted

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.

 

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)

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...