What the general way of storing custom objects in sessions?
I\'m planning on keeping my cart in a session throughout the web application. When that user logs out, th
ASP.NET session corresponds to browser session - it is independent of whether user is authenticated (logged in) or not. So you should not have any issue with regards to guest/member sessions. I would advise you to expose the current shopping cart via static accessor property - for example
Class ShoppingCart {
public static ShoppingCart Current
{
get
{
var cart = HttpContext.Current.Session["Cart"] as ShoppingCart;
if (null == cart)
{
cart = new ShoppingCart();
HttpContext.Current.Session["Cart"] = cart;
}
return cart;
}
}
... // rest of the code
}
Few things to consider here: