Shopping cart online store: data in cookies or in database


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
57 views
Can't decide where to keep data about incomplete purchases user to the online store?
To put items in the cart in the session, cookies, or store them in a separate table in the database, which is periodically cleaned..?
Went through major stores(amazon, ozon) — in the cookies they leave only the session ID.
by | 57 views

7 Answers

0 like 0 dislike
Previously, it was decided to store the cart in a cookie.
Now good practice is to store the cart in the database.
\r
The advantages of storing at DB:
1) the Basket can be stored indefinitely.
2) Basket is not lost if the buyer has logged in from another browser/computer.
by
0 like 0 dislike
Keep the basket a month in session. Registration is not, so the 2nd item listed Bartez impossible.
If in addition the number of products and id you need to store more vskie configuration of goods, or other info, it will be much easier to hold in the structures of language are serializable in the session than in the database tables.
by
0 like 0 dislike
homm, "Keep the basket a month in session"
What is it like?
by
0 like 0 dislike
And I store in cookies and Nitsche, normal. Cons voiced. Pros — instant add to cart and instantly change the number of items/amount. Stored as json. What would cook have filled you just have to put in the basket
by
0 like 0 dislike
As I recall, the session open until the browser is closed and depending on the settings on the server.
Cons:
  • the user session can be removed when auto-purging sessions
  • if storing sessions made on the hard drive and purging is not configured, unable to face a situation when you have the inode will end.
  • not guaranteed to save state when you close the browser


It is better to use this practice:
  • for a user to create a database in the basket if not created.
  • next, get an id to save it in a cookie or localstorage.
  • next, we synchronize the cart ajax requests - added product, sent a request to the database.

One of the advantages of this approach:
  • the items in the cart will remain when re-entering user(the main thing not to forget when setting the cookie storage time necessary to put)
  • there is an opportunity to gather statistics on the baskets users who have not made the order
by
0 like 0 dislike
Better basket to store on the server side. Database, NoSQL, file — this is the choice. I would suggest Redis, for example. There already is tracking the relevance of the data.
by
0 like 0 dislike
cookies are limited in size, so you can cookies to store session ID, and session on the server. And every day cecati demon entries and remove that were not carried out.
by

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
110,608 questions
257,186 answers
0 comments
28,100 users