469,358 Members | 1,659 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Shopping Cart - database vs session

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
Nov 18 '05 #1
2 2115
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.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Paul Hobbs" <ph****@blueprint.net> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2
Session dont work well in a webfarm environment. This is the biggest
advantage to Database or StateServer Session implementation.
Cheers,
Greg Jackson
PDX, OR
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Erik | last post: by
2 posts views Thread by Don Grover | last post: by
1 post views Thread by Jia Sun | last post: by
1 post views Thread by Adil Akram | last post: by
2 posts views Thread by Guadala Harry | last post: by
2 posts views Thread by G.E.M.P | last post: by
reply views Thread by TRB_NV | last post: by
3 posts views Thread by Paulo | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.