(1)代码如下:
public String GetShoppingCartId() 
{
System.Web.HttpContext thecontext = System.Web.HttpContext.Current; if (thecontext.User.Identity.Name != "") 
{
return thecontext.User.Identity.Name;
} if (thecontext.Request.Cookies["IStore_CartID"] != null) 
{
return thecontext.Request.Cookies["IStore_CartID"].Value;
}
else 
{
Guid tempShoppingCartId = Guid.NewGuid();
thecontext.Response.Cookies["IStore_CartID"].Value = tempShoppingCartId.ToString(); return tempShoppingCartId.ToString();
}
}
(2)我的疑问:当我登陆后,选中商品1,添加到购物车,再选中商品2,商品3,添加到购物车,然后去结算时候,在这其间是如何保障我选的商品1,商品2,商品3是在同一个购物车的ID号下添加的商品。是不是"System.Web.HttpContext thecontext = System.Web.HttpContext.Current;"起的作用???谢谢!