Hello Lara,
Excellent question.
Typically you want to minimize the number of database trips, as well as minimize
the amount of information you hold in memory. There are several ways of
accomplishing this.
First, in a shopping cart environment what are the bits of info you need
to track? User Credentials (are they logged in, what rights do they have,
etc), Shopping Cart Contents, Misc Preferences.
User Credentials are easy.. ASP.NET has a rich authentication and authorization
mechanism. This topic is too diverse to discuss thoroughly here, but you
can find plenty of information on the sublect on the web and in books.
Shopping cart.. well.. we certainly do NOT want to store every bit of info
about each item in the session. All we really need is the ProductID and
Quantity. Armed with these two peices of info we can construct a checkout
page with a single database call.
The session would be a good place to store the ID and Qty.
Misc Preferences is more difficult.. they can include anything from prefered
web site display colors/fonts to rating preferences to all kinds of things.
Each preference should be taken on a case by case basis and stored/accessed
accordingly. Just remember to design to minimal system impact. Dont read
the database more than you have to. Dont store information in the session
that is only occasionally used.. etc.
-Boo
Hi all,
I have an assignment due (asp.net in c#) that requires us to think of
a large-scale online stores allowing for thousands of users at a time
to be logged in, creating accounts and so on. We have been told to
choose either sessions and / or databases to hold necessary
information but I'm a bit stuck (and very interested) in how it would
really work! Can anyone point me in the right direction here? A web
reference, a good example online or something please? I don't think
this course is very indepth, so forgive me for the silly questions...I
just don't see how using a session on one or even a few servers would
be the best thing to do, nor would calling and somehow storing
somewhere else (in the session too???) all the user's account
information when we're talking about thousands of users at a time -
wouldn't this clog up the memory, speed or whatever else of the web
server(s)? How is it really done (in asp.net and c# of course!)?
Many thanks in advance for any guidance :)
Lara