Migrating a Web Server to IIS 5.0

Previous Topic Next Topic

Maintaining State

There are several schemes commonly used in CGI applications for maintaining state information about the client session on the Web server. Some of these involve scripts that save and restore data from server-side text files. Others involve embedding state in the client-side HTML (for example, using hidden form fields). Some CGI applications even maintain state by setting themselves up as “mini Web servers” for the duration of the session, intercepting incoming HTTP requests. Many Web developers have moved to using browser-based cookies for storing state information.

ASP provides built-in state management through the Session collection of variables, making session management transparent to the Web developer. When a client first connects to the application, the server can send a session cookie that identifies the new session. As the browser accesses other pages in the application, the cookie is retrieved by the system and is used to manage state.

For example, consider an ASP page in which the user’s login name is retrieved and assigned to a session variable:

   Session("login_name") = Request.Form("login_name")

The value of login_name will be available to all other pages within the application, until the session times out (the default is 20 minutes, but it is configurable) or is explicitly abandoned.


© 1997-1999 Microsoft Corporation. All rights reserved.