Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shopping Cart

Status
Not open for further replies.

BigBadDave

Programmer
May 31, 2001
1,069
EU
I am building an e-comm app in php and have come to the cart area of the app but I havn't done this in php before anybody got any pointers Regards

Big Bad Dave

davidbyng@hotmail.com
 
there are many ways to do the cart in PHP.
You can use cookies to save the cart in the user computer, but you are restricted to 20 cookies per user, or use sessions and here you lost the cart as soon as the user closes the browser.

You can too use a database to save the shopping cart of a user, it's the most polite way to do the job, but you can have too much garbage in the database. You have to do a garbage collect, and here the decision is yours.

I thing there are too many scripts to help you out. Try and check in Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Hi,
Is there a session on end thing like ASP because I want to clear the database stuff out when session ends Regards

Big Bad Dave

davidbyng@hotmail.com
 
Yes, but you have a problem. If the user closes the window, the session will terminate by garbage collect. And in this way you cannot remove the data from the database.

What you can do, is recreate the sessions, creating all the functions, and when you are GC you remove the session and the junk in the DB. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
I would do it as following. As long as the user shops, fill the session and do not write to the database. Only when the user confirms the order write all session data into the database. This will result in a clean database which is also usefull. mcvdmvs
"It never hurts to help" -- Eek the Cat
 
Yes, but what would you do if, for example, the costumer computer crashes, or for example, lights out? The user loose the cart, and he have to start all again.

Use some GC. For example running once in 100 times, cleaning all records not changed in the last week.

This way, inform the user that the cart will be availble only for one week. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Yeah that is what i'm gonna do if stuff is older than 2 days the delete it Regards

Big Bad Dave

logo.gif


davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top