Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

best way to code a basket


I'm just about to start developing my first e-commerce basket and will be using .net 4.

I'm wondering if there is a "standard" way of doing it these days?

Do I use cookies, sessions or something else?

Presumably upon adding an item to the basket it just gets stored with a "basket or session id" and then it is the basket or session id that is available on all pages to pull up the basket?

I'm just looking for a basic overview of the best way to do things to ensure the session can't be lost and where I am not going to come up against issues with cookies disabled etc.

Would appreciate your thoughs and guidance...
  • 2
  • 2
1 Solution
A sessionID (that uses cookies) could be used to track the user and you can store the cart items in the database.

You can take a look at this free open source shopping cart that uses .net 4 :


It's a pretty good system that I am currently using for web stores.

If you want something a little less complex and in Visual Basic,
you could take a look at this book that has good shopping cart code :


You can buy it used for $0.08.
I actually used this book to build an ecommerce website that did very well
and was making about $500,000.00 a year.
Basically a shopping cart can be reduced to several pages all using Session Varaibles, response.redirect("review.aspx"):

Product Page
>>lists details of product and allows users to choose to put in shopping cart
Shopping Cart
>>Shows all products desired to be purchased, allows the user to manage list
Purchase Page
>>usuallty a purchase page that sums up the total dollar amount(thats all the merchat cares about), onClick redirects them to purchase page
    will they enter credit card info.  You would find fields such as email addres, name, dropdownlist  of states, credit card number(you can only use last 4 digits on web form)
Review Page
>> after the user enters details, they can confrim and submit order to merchat processor
On Complete Order page
>>most use an API like authorize.net, if there are errors, return an error code, other wise reward teh user with a confirmation order page and manage their accounts, ie get free point on database
scm0smlAuthor Commented:
Thanks guys.

I think one of the biggest things I wanted was to make sure there was no chance of the basket being dropped because of a timed out session etc.

I have gone with the idea of storing a basket guid in a cookie and then just  pulling the basket data from the database using that.

Anyone have any issues with that way?
scm0smlAuthor Commented:
used my own answer...

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now