Get a string of Shopping cart cookie data
Description: Returns a string with all the cookies cocatenated together. This can be passed to a business tier to retrieve a table of all shopping cart items.
Link: http://www.codekeep.net/snippets/0e1b66ac-80dd-4c9f-9750-868758b1a243.aspx
protected string GetCartString()
{
HttpCookieCollection hc = new HttpCookieCollection();
hc = Request.Cookies;
string ItemsQuantity = "";
foreach (String sc in hc)
{
HttpCookie c = hc[sc];
ItemsQuantity += c.Value.ToString().Trim() + ",";
}
//trim end comma
if (ItemsQuantity.Length > 0)
ItemsQuantity = ItemsQuantity.Substring(0, ItemsQuantity.Length - 1);
return ItemsQuantity;
}





