Shopping basket

When we write a shopping cart, should we store the shopping cart information in a database with a session identifier or only save session variables? Why?

+3
source share
4 answers

If the user cannot save his shopping cart, the session ID will be fine, just remember that he can change if he starts working through the browser.

If you want the user to be able to store and retrieve the cart, you cannot rely on the session identifier. In this case, you need a user account, and then bind the cart to the user ID.


[EDIT]
, , , . , - cookie , /.

, , , , , . cookie , . , .

100% , , , .

+1

, .

, 2 ( - ), db. ( ). , .

, , .

, ( ), , , cron, ( ).

+1

, , , . , , .

There is no problem storing the shopping basket in the database, and I would recommend this, since you can see the items that people add to the basket and then do not buy, which may indicate some problems with the price.

So the short answer is .... add it to the database :)

+1
source

save it to the database. This is not so difficult to do, and it will give you the best results. In addition, it allows you to track items that people put in their baskets, but do not purchase.

0
source

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


All Articles