1
在這裏,我要追加新產品的產品ID的Cookie名稱車所以誰能幫助我與它如何追加對購物車的細節一個cookie在asp.net C#中
protected void lnkAddToCart_Click(object sender, EventArgs e)
{
HttpCookie CartCookie=Request.Cookies["cart"];
if (CartCookie != null)
{
string str = CartCookie.ToString();
str= str + ";"+ _ProductID.ToString();
Response.Cookies["cart"].Value = str;
}
else
{
CartCookie = new HttpCookie("cart");
CartCookie["Cart"] = _ProductID.ToString();
CartCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(CartCookie);
}
}
,並且你有什麼問題找回? CartCookie [「購物車」]更改爲CartCookie [「購物車」] –