Saving temporary data for a shopping cart

I make a basket for my site.

What is the best solution, storing data in a session or storing data in a table? If I save it in the table, how and when will I delete the entries in the table (i.e. when they will not be bought by the user, but in the table)

+3
source share
4 answers

What I do in my particular case is to store information in a CartOrder table. Pending status. When the process is complete, I insert the information into the order table and mark CartOrder as done (or delete). For me, CartOrder is the intention of the purchase, Order is the purchase in its own way.

, CartOrder, (, , ). , , , , . .

+2

. . , , , , , , , .

, , , cron , , .

+2

, .

$_SESSION, .

, -, .

, , , , > 10 000 .

For normal products, SESSION is perfect.

+2
source

Take a hint from Amazon, save the data in a database and never delete it.

How much will you get from the items in the basket? How much does it cost you to store the contents of the cart? If someone leaves their cart and then returns to your site in a year, they will still want to receive items in the basket.

+1
source

Source: https://habr.com/ru/post/1723307/


All Articles