O'Reilly logo

Web, Graphics & Perl/Tk Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Saving CGI State

Lincoln D. Stein

We live in a stateful world. Just to be certain, I collected a few examples this morning:

  1. Today I’m in a certain frantic state of mind because this article is due. I’ll be this way for at least the rest of the afternoon, or until the article is done, whichever comes first. This is an example of a short-term state.

  2. The federal budget is in a dreadful state of affairs that won’t clear up until the last state has voted in the general election. This is an example of a long-term state.

  3. The weather is truly lovely today with balmy spring weather and bright sunshine. Because this New England, however, it’ll stay nice only until sometime tonight, when the weather report predicts a snowstorm followed by an iron frost. This is typical of an unstable state.

If the world has state, why doesn’t the Web? It would seem reasonable for the Web to have some memory. After all, people do tend to hang around a site for a while, exploring here and there. It would seem only polite for a web site to remember the user who’s been rattling around inside it for the past hour. But the HTTP protocol is stateless. Each request for a document is a new transaction; after the document is delivered, the web server wipes its hands of the whole affair and starts fresh.

The HTTP protocol was designed that way because a stateless model is appropriate for the bulk of a web server’s job: to listen for requests for HTML documents and deliver them without fuss, frills, or idle chitchat. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required