Exploiting the Information World
ITEC-2110 - Fall 2000

These exercises are part of your grade!

For each exercise that you complete during class you must make record your results to show the TA (or show the TA your screen). If you don't have time to complete everything during class you must record your results and give them to the TA by the next class meeting.

EIW Exercises: HTTP Cookies


1. Perl CGI system based on HTTP Cookies

The general idea is to repeat exercise 16, but to use a cookie to hold the shopping cart instead of using hidden fields.

NOTE: If you want to use the GetCookies subroutine described in the lecture notes you should grab this version of the eiw-cgi.pl library: eiw-cgi.pl.

Develop a CGI application that allows users to order products by typing in the name of the product and pressing a submit button. Your CGI program should then add the new item to a list of items already ordered by the user (using the same method), and send back another copy of the form. You must also provide some way to clear the shopping cart (erase the cookie!)

Your form should look something like this:

Item Name:


You should use an HTTP cookie to propogate the state of the "shopping cart" from one invocation of your CGI to the next. In other words, when a user submits the form using the "Add Item" button, the new item is added to an existing list of items that came from the value of the cookie that accompanied the request.

When the user clicks on "Go to Checkout" this should run a CGI program that generates an HTML document containing the contents of the shopping cart (it gets the value of the cookie and sends it back to the user in a nice format). This should be provided as a seperate function (I don't want to see the shopping cart on every page - only when I press the "Go to Checkout" button").

When the user clicks on "Clear Shopping Cart" you should throw away the current shopping cart by erasing the cookie (set the value to the empty string). The CGI that is run to clear the shopping cart should send back the original form.