SetVariable Method  
 

Create or change the value of a CGI environment variable for the specified client.

Syntax

object.SetVariable( ClientId, VariableName, VariableValue )

Parameters

ClientId
An integer that identifies the client session.
VariableName
A string that specifies the name of the header field. Header names are not case-sensitive and should not include the colon which acts as a delimiter that separates the header name from its value.
VariableValue
A string variable that contains the new value of the response header.

Return Value

A Boolean value that specifies if the method was successful.

Remarks

The SetVariable method will change the value of a environment variable for the specified client session, typically within an OnCommand event handler. If the VariableName value matches an existing variable, its value will be replaced. If the variable is not defined, then a new variable will be created with the given value. The value of an environment variable can be obtained using the GetVariable function.

The server will automatically create a number of different environment variables that will be passed to a program or script executed by the server. These variables are defined in RFC 3875 as part of the Common Gateway Interface (CGI) 1.1 specification. The following variables are defined by the server and should not be modified directly by the application:

Variable Name Description
AUTH_TYPE The authorization scheme used by the server to authenticate the client session
CONTENT_LENGTH The length of the request data provided by the client
CONTENT_TYPE The MIME type that identifies the type of content provided by the client
DOCUMENT_ROOT The full path to the local document root directory on the server
GATEWAY_INTERFACE The version of the Common Gateway Interface that is being used by the server
PATH_INFO The resource or sub-resource that is to be returned by the program or script
PATH_TRANSLATED The path information mapped to the server root document directory structure
QUERY_STRING The URL encoded query parameters passed to the program or script
REMOTE_ADDR The network address of the client sending the request to the server
REMOTE_HOST The same value as the REMOTE_ADDR variable
REMOTE_USER The username specified as part of the authentication credentials provided by the client
REQUEST_METHOD The method used by the client to request the resource
REQUEST_URI The URI for the script provided by the client
SCRIPT_FILENAME The full path to the program or script on the server
SCRIPT_NAME The path to the program or script specified by the client
SERVER_NAME The hostname or IP address of the server that the client connected to
SERVER_PORT The port number that the client used to connect to the server
SERVER_PORT_SECURE This variable has a value of "1" if the client connection to the server is secure
SERVER_PROTOCOL The version of the server protocol used
SERVER_SOFTWARE The server identity string which specifies the application name and version

In addition to the environment variables listed, the server will also create variables that are prefixed with "HTTP_" that are set to the value of request headers that are not otherwise defined. For example, the HTTP_USER_AGENT variable will be set to the value of the User-Agent header provided by the client as part of the request.

Note that calling the SetVariable method from within the OnExecute event handler will have no effect because it occurs after the CGI program or script has completed execution. To create or modify environment variables for the client session, it should be done within an OnCommand event handler.

This method will not change the environment block for the server process. Each client session is allocated its own private environment block which is inherited by the CGI program. When the client session terminates, the memory allocated for its environment is released.

See Also

GetHeader Method, OnCommand Event, OnExecute Event