public Cart GetCart() { Cart cart = (Cart)Session["Cart"]; if (cart == null || cart.GetCount() == 0) { cart = new Cart(); List <Product> prList = new List <Product>(); long id = 0; var auth = Request.Cookies["Auth"]; if (auth != null) { long.TryParse(auth.Values["UserID"], out id); prList = pr.CreateCart(id); } else { prList = pr.CreateCart(null); } foreach (var p in prList) { cart.AddItem(p); } Session["Cart"] = cart; } return(cart); }