php - Store Session ShoppingCart in db -


i'm developing laravel app , want implement laravel shopping cart in it. before so, have 1 question: figured out, shopping card information stored in session. if know log out/close browser/etc., session gone, shopping cart.

how can store shopping cart information in db , restore it, when needed? and: when save in db? , when out again?

file based session or database based session both destroy on logout,close browser etc.

you need create 2 tables in database

table_shopping_cart => id, session_id, user_id, created_at, updated_at, invoice_id etc

table_shopping_cart_items => id, cart_id, item_name, item_qty, price etc

and can run scheduler or cron query specific date/time delete expire entries both table.


Comments