Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php shopping cart [closed]

Tags:

php

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?

like image 208
wailynnoo Avatar asked Mar 18 '26 12:03

wailynnoo


1 Answers

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).

like image 173
Simon marc Avatar answered Mar 21 '26 07:03

Simon marc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!