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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a shopping cart, session or database?

Status
Not open for further replies.
Aug 23, 2004
174
US
I'm working on building a shopping script and have come to a small issue and can't decide which way to go. I can store the cart in a session or in a database. My problem is I'm not sure which is the better route to go.

Any recommendations? Pros and Cons?

Thanks,

Joe
 
Hi

You mean the products already put in the basket but not actually ordered yet, right ?

I would store them in session. That way the cleanup of abandoned baskets ( neither ordered or canceled, just timed out ) is done automatically.

Beside that, usually a short summary ( amount, total value ) is displayed on every page while the user browses the products. So better keep those data handy and not query them from the database every time.

( By the way, the session data can be physically stored in a database, if needed. )


Feherke.
 
Yeah, I meant the actual "shopping cart".

I was leaning towards sessions but then I was thinking about having abandoned cart info saved could be useful too.
 
I built a shopping cart with RBS Worldpay integration for a tek-tips member about a month ago (offline). I am happy to share it and to continue working on it/adding functionality in return for engagement in giving feedback on functional enhancements.

this member required the cart data to be stored as a session variable. I was in two minds throughout the build but in the end concluded that a database would have been much better.

the main reason for this was ensuring cart continuity across browsers and browser sessions for logged in users (return customers). and even more importantly many payment providers require that payment interaction is actually conducted on their site. then they hand back a token to you. In order to register the cart as having been paid (and therefore to empty it) you have to do some non-trivial coding that took me more than an hour to get right from a logic perspective (although it was late at night).
 
Hi

jpadie said:
in the end concluded that a database would have been much better
One thing came in my mind as a pro database argument : if you want to set reservation on the stocks in the baskets, so the same pieces to not be put in multiple baskets in the same time.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top