session, cookie, or mysql database for PHP shopping cart ?

  • Thread starter Thread starter smashhell
  • Start date Start date
S

smashhell

Guest
I am trying to create a shopping cart with PHP and couldn't decide which to use.

Is it better to store the cart info in a session/cookie, than use the info to look up product in database to sent to admin.

Or is it better to store all the cart info in the database and work it from there ?

Which way of creating the shopping cart is simpler and which is better ? Are there any better ways of doing it?

Thank you very much !
*p.s. No advertisement for shopping cart software please ! I want to make it myself.
 
You could do either, but shopping cart items would typically go in the session. In most cases, you'll want to keep access to the database as limited as possible (it tends to become the bottleneck), so if you can offload it to your web server (which is what you're doing when you store this stuff in a session), you should. It's also the simpler solution.
 
Back
Top