In my application, I need to create an online shop where user has his/her own login page. After login he add some products in the cart and process for checkout. So for that I did the functionality of the entire process. But I’m facing an issue when different user login to my application and when he check the cart, it’s showing the previous user’s selection over there. For example,
User1 login to the application and add product1, product3 in the cart and proceed further. After User1 logout, User2 comes and try to login to my application. Now when User2 check the cart it’s showing that Product1 and product3 are already selected in the cart.
How can I resolve the issue?
To resolve this issue, you need to associate the Cart object with the entity “Account” (or a specialization of it). Now when you display the cart to the user, you need to retrieve the cart that is associated with the currently logged in user.