ASP.NET 中的访客/会员会话
你好,我有一个购物车类和购物车类。现在的问题是关于会话的。我已经为此奋斗了几个小时,但问题是同一场会议是由一位客人和一位会员进行的。因此,无论您是否登录,都只有一个会话存在相同的购物车。
我的课程如下。
Class Cart
{
int ProdId;
float TotalPrice;
float UnitPrice;
int Quantity;
public Cart(int id)
{
......//initialize variables here
}
}
Class ShoppingCart{
public List<Cart> Items = new List<Cart>();
}
public void AddItem(ProdId)
{
Cart = new Cart(ProdId)
}
}
我应该如何为会员和客人保留课程?我希望能够将购物车以及客户信息保留在会话中。如果访客在线,然后登录,则必须更改会话。
Hello I have a class Cart and class ShoppingCart. Now the problem is about sessions. I have been battling with it for hours, but the issue is that the same session is being by a guest and a member. So it doesnt matter if you login or not, theres just one session where the same cart exists.
My classes are below..
Class Cart
{
int ProdId;
float TotalPrice;
float UnitPrice;
int Quantity;
public Cart(int id)
{
......//initialize variables here
}
}
Class ShoppingCart{
public List<Cart> Items = new List<Cart>();
}
public void AddItem(ProdId)
{
Cart = new Cart(ProdId)
}
}
How should I go about keeping a session for a member and a guest? I want to be able to keep the cart in the session, along with the Customer information. the session must change if a guest is online, and then signs in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户登录时,您可以执行 Session.Clear() 吗?
或者,不要直接访问购物车,而是使用一个属性来处理检查用户是否登录,如果登录,则销毁并删除用户。使用正确的设置重新创建?
You could do a Session.Clear() when the user logs in?
Or instead of directly accessing the cart, have a property where you handle checking if the user is logged in or not, and if he is, destroy & re-create with the proper settings?