I used multidimensional cookie to store a cookie in my application.
For example
HttpCookie MyCookie = Request.Cookies["Temp"] as HttpCookie;
if (MyCookie != null)
{
MyCookie.Values["SID"] = Session.SessionID;
MyCookie.Values["NAME"] = "NAME";
MyCookie.Values["abc"] = "abc";
MyCookie.Values["xyz"] = "xyz";
...
}
Now to retrieve this multidimensional cookie I used.
string s = Request.Cookies["Temp"]["SID"]
My question is I want to expire only “SID” value from the “Temp” cookie. I tried with this
Request.Cookies["Temp"]["SID"] = null;
but it’s not working. What should I do clear particular index from multidimensional cookie?
This is already answered in the following question: ASP.NET Cookie Sub-Value Deletion
HttpCookie.Values is a NameValueCollection, so you can modify that collection – but you will need to re-send the cookie as a new one to overwrite the old one:
This is also explained in the following MSDN page: http://msdn.microsoft.com/en-us/library/aa289495(v=vs.71).aspx#vbtchaspnetcookies101anchor9