0👍
✅
There are two possible solutions. One is handled on client side and other on server side. I would recommend to go with sever side which is solution 2, so that even when user opens the cart later, they can still see the items they added in cart. Amazon gas similar behavior.
Solution 1(client side): You can save the shopping cart details in localStorage or sessionStorage depends on your need and fetch the data from there when redirected to cart page
Solution 2(server side): This is done with the help of Backend in your project. Everytime you add a item in cart, you should send that information to BE(backend) and whenever you come to cart page, you should ask BE about the cart details
Source:stackexchange.com