Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a main cookie say "MAINCOOKIE" and with that I keep adding the dynamic cookies into "MAINCOOKIE". I want to delete only the selected cookie from the list of cookies either server side or Client side. I tried clearing in server side, I am able to clear the entire MAINCOOKIE whereas I am not able to clear a particular cookie which is inside "MAINCOOKIE" only in IE, It works finein FF. So I tried deleting from clientside, but I find no option to delete the specific cookie from the "MAINCOOKIE"

Thanks in advance
Posted
Comments
Sandeep Mewara 5-Jun-12 10:24am    
Sharing your code might help members to respond back more specifically.

1 solution

This is how i add my cookie

if (Request.Cookies["MainCookie"] != null)
                       {
                           if (Request.Cookies[MainCookie].Values["subcookie_" + productId] != null)
                           {
                               existingProductId = productId;
                               existingCookie = Request.Cookies["MainCookie"].Values["subcookie_" + productId].ToString();
                               string[] splitCookie = existingCookie.Split('$');
                               quantity += Convert.ToInt32(splitCookie[1]);
                               isCookieExistAlready = true;
                               HttpCookie aCookie;
                               aCookie = new HttpCookie(Request.Cookies["MainCookie"].Values["subcookie_" + productId]);
                               aCookie.Expires = DateTime.Now.AddDays(-1);
                           }
                       }
                       else
                       {
                           HttpCookie mainCookie = new HttpCookie("MainCookie");
                           Response.Cookies.Add(mainCookie);
                       }
                       string nameofCookie = string.Concat("subcookie_", (isCookieExistAlready ? existingProductId : productId));
                       Request.Cookies["MainCookie"].Values[nameofCookie] = productId + "$" + quantity;
                       Request.Cookies["MainCookie"].Expires = DateTime.Now.AddDays(1);
                       Response.Cookies.Add(Request.Cookies["MainCookie"]);


After Adding I want to delete only particular subcookie from the Maincookie
How do I do that?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900