When we write a shopping cart, should we save cart info in the database with session id or should we save only session variables? Why?
Actually that depend what do you want to do with it.
If you want that the a login user can get his cart 2 days after (or whatever) you should put it in db. But you can't save a no-login user cart (or you save it only to track item). So you have to check every times if the user is log.
The advantage is if the user use another browser or computer, he will still have is cart.
For the databases it must not change anything, cos normally you will have a history (if the user buy the product) so you just had a field history which is a boolean, and have a cron who clean history every month (if you need it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With