Shopping Cart - database vs session

P

Paul Hobbs

Hi All,

I am developing a site that makes use of a standard shopping cart. Anyone
can add items to the cart, but only registered users can actually check out.
When a user tries to check out, if they are not logged in they will be
prompted to either login or register before they can proceed to the
checkout.

There is NO requirement to allow users to add items to a shopping cart, and
return at some time in the future and still have those items in the cart.

My question is this: what are the pros and cons of storing the contents of
the cart in the database versus storing the cart contents in a session
variable. The author of one of my reference books (on ADO.NET) provides an
example of each approach, but says his preference is for a database driven
cart. I'm not sure why this would be - any thoughts?

Thanks in advance,

Regards,

Paul Hobbs
 
C

Chris Jackson

Session Variables:
Pro - Very fast access
Con - Server memory is limited and expensive, using too much hinders
performance for the entire machine

Database:
Pro - Hard drive memory is cheap and doesn't hinder performance
Con - Much slower access

The usage pattern of your application and performance requirements will
guide you through the tradeoffs here. If you plan to have 1,000,000
simultaneous users, and you aren't judicious with your session variables,
you can run into trouble. If you plan to have 10 simultaneous users, they
might appreciate the improved performance of using session variables.
 
J

Jaxon

Session dont work well in a webfarm environment. This is the biggest
advantage to Database or StateServer Session implementation.


Cheers,


Greg Jackson
PDX, OR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,799
Latest member
Mercury_Dev

Latest Threads

Top