Use only one session to solve the shopping cart (1)

Source: Internet
Author: User
session| Shopping Cart | solution--------------------------------------------------------
Original Author: Magnus Lindberg
Original link: http://www.asptoday.com/articles/20001025.htm
Translation: Pine
--------------------------------------------------------

At present, the shopping cart has become the core of the user interface in e-commerce system, it can clearly tell the customer the name and quantity of the goods purchased, the user can delete the purchased goods at any time in the shopping cart. In addition, for example, when users want to buy 2 T-shirts instead of one, they need to modify the number of items. These basic features are all the shopping cart systems should provide.

When using a shopping cart, you may be in a dilemma in comparison between function and performance. There are several options in front of you:
1. Do not use the shopping cart, this is of course the best way to save server resources (nonsense!) ;
2. Each commodity information is stored in the session variable, but this method because of the use of a lot of session variables, very expensive server resources (can be called Server killer);
3. Use the database to support the shopping cart, but every time you add items to the cart to read and write to the database, so this method is also undesirable;

Accessing the data in memory is certainly much faster than in the database (accessing the data), so we should process the data in the server-side memory. Session provides us with this function, as long as you are not too abused, it is a very good choice to solve the problem.

Have you ever thought about using only one session to write a shopping cart system that is both functional and resource-saving?

This article describes how to write a shopping cart class with VBScript (translator: A VBSCRIPT5.0 or later version of the script engine), which you can easily include in the ASP page. I am not using component technology for the following two reasons: first, I just want to use pure ASP code to write this program, and second, not all servers can let you use components, especially those free components.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.