Hi James,
This is a more complicated problem, deleting an individual subkey. You
cannot simply reset the expiration date for the cookie, because that would
remove the entire cookie instead of a single subkey. The solution instead is
to manipulate the cookie's Values collection, which holds the subkeys. First
recreate the cookie by getting it from the Request.Cookies object. You can
then call the Remove method of the Values collection, passing to the Remove
method the name of the subkey to delete. Then, as usual, you add the
modified cookie to the Response.Cookies collection so it will be sent in its
modified form back to the browser.
The following code shows how to delete a subkey. In the sample, the name of
the subkey to remove is specified in a variable.
Dim subkeyName As String
subkeyName = "userName"
Dim aCookie As HttpCookie = Request.Cookies("userInfo")
aCookie.Values.Remove(subkeyName)
aCookie.Expires = DateTime.Now.AddDays(1)
Response.Cookies.Add(aCookie)I hope this helps,Regards,Stuart
"James" <ja*********@ntlworld.com> wrote in message
news:5f*****************@newsfe3-win.ntli.net...
Help!
I've made a cookie with a key called 'List' and
subkey 'item3' and assigned it a value of "3"
Response.Cookies("List")("item3")="3"
How do I now delete the subkey "item3" without
deleting any other subkeys that might be in 'List'???
J