// The static constructor is called as soon as the class is loaded into memory. public static ShoppingCart GetShoppingCart(string UserName) { // If the cart is not in the session, create one and put it there. if (HttpContext.Current.Session["MyShoppingCart"] == null) { ShoppingCart cart = new ShoppingCart(); cart.Items = new List<CartItem>(); cart.RetrieveFromDB (connectionString, UserName); /****** * TODO: Load any previously saved items into the shopping cart from the database. */ // Save the shopping cart in the Session variable "MyShoppingCart". HttpContext.Current.Session["MyShoppingCart"] = cart; } ShoppingCart temp = (ShoppingCart)HttpContext.Current.Session["MyShoppingCart"]; if (temp.Items != null) temp.Items.Clear(); temp.RetrieveFromDB (connectionString, UserName); HttpContext.Current.Session["MyShoppingCart"] = temp; return (ShoppingCart)HttpContext.Current.Session["MyShoppingCart"]; }