判断用户是否登录,获取用户的customerID
public static string GetShoppingCartID()
{
HttpContext hc = HttpContext.Current;
//如果有登录ID就返回登录ID
if (!string.IsNullOrEmpty(hc.User.Identity.Name))
{
return hc.User.Identity.Name;
}
//如果有临时ID就返回临时ID
if (hc.Request.Cookies["Customer"] != null)
{
return hc.Request.Cookies["Customer"].Value;
}
else //创建一个临时ID
{
string tempid=Guid.NewGuid().ToString();
hc.Response.Cookies["Customer"].Value = tempid;
return tempid;
}
}