Open CODE-AXION opened 2 years ago
Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).
Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).
But how can I store the session to the database , because there might be multiple session for multiple users ? And the session id will also get changed after login ? I am very confused idk how to do it properly 😞.
Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).
But how can I store the session to the database , because there might be multiple session for multiple users ? And the session id will also get changed after login ? I am very confused idk how to do it properly 😞.
No you dont save the session to the database. The cart can be either in the session or the database but not booth. A loaded cart is not on the database. https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L399 Just store the cart with a tmp identifier and load it after the session is renewed.
i want to make a shopping cart where if guest user adds items to cart and when he logs in all the guest cart items should be shifted from session to database ? how can i achieve that ?