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?