Since HTTP is a stateless protocol, CGIs have to do extra work in order to remember
information about previous access. One way of maintaining state information is to
use the cookie manager to store information in cookies and to embed the associated
cookie identifier in documents generated by the CGI.
The following CGI either takes a start or next parameter specifying
an HTML document containing a form.
When it receives a start parameter, it first creates a cookie, otherwise
it uses the cookie specified by the Magic_Cookie parameter.
The CGI stores any parameters from the request content with the cookie.
If a new document is specified (through the start or next parameters),
it is loaded from disk and all occurrences of the string -*Cookie*- are
replaced with the cookie id. Also, all occurrences of the string -*SCRIPT*-
are replaced with CGI's name. This document is then returned to the browser.
If there is no new document, the CGI generates a document listing all the information
the CGI has collected and then destroys the cookie.
This CGI is fairly general purpose since most of the information that changes (HTML
files) is stored outside of the CGI.
/cgi-bin/examples/ck_clnt.vi?start=/cgi-bin/examples/interest.htm