CGI and Perl

Shopping Cart Applications

  • Implementation Issues
  • MiniVend Package
  • Installation and Configuration
  • Overview of Features
  • Use and Customization
  • A Few Words About Security

The idea of shopping on the World Wide Web is an intriguing one. Imagine the convenience of purchasing items with a simple point-and-click operation. This chapter covers the details of what are called shopping cart applications. It also describes the MiniVend package, which was written by Mike Heins and based on the Vend package written by Andrew Wilcox.

Implementation Issues

Several issues need discussion before diving right into the example. I first describe a few basic problems with CGI and the ways around these problems. I also describe some of the advantages of CGI over static HTML pages. Of course, security is of major concern, especially when talking about Internet commerce. I attempt to address some of these issues and then analyze the MiniVend package and how you can use it to set up your virtual store quickly.

Implementation Issues

Several issues need discussion before diving right into the example. I first describe a few basic problems with CGI and the ways around these problems. I also describe some of the advantages of CGI over static HTML pages. Of course, security is of major concern, especially when talking about Internet commerce. I attempt to address some of these issues and then analyze the MiniVend package and how you can use it to set up your virtual store quickly.

Maintaining a Persistent State

One of the biggest drawbacks of HTTP and CGI is the lack of a persistent state. The nature of the HTTP protocol is such that each request made on a server is a separate and distinct connection that ends when the server responds with a result. This approach is perfect for the concept of surfing the Web but not so perfect for the concept of a session consisting of multiple requests. When you're shopping for an item at a Web site, you most likely want to "surf " around in the site's product catalogs and choose what you want to buy as you're going along. Doing so requires
several separate and distinct requests from the browser to the server. However, you still want to maintain information such as the products selected, the running subtotal, and so on.

This lack of a persistent state can be solved in a few different ways. One way is to use hidden form fields (see Chapter 5, "Putting It All Together"). Another is for the server to keep some file
associated with the session for the duration of the session. Yet another is to use what are known as cookies; this approach is a client-based persistence solution.