4.3 COOKIE

Sends a cookie to the web browser. The COOKIE keyword requires the parameters described in the following table, in the order listed:

Parameter

Description

Name

The name of the cookie.

Value

The value of the cookie.

Domain

The domain to which the browser will respond with the cookie.

URL

The URL to which the browser will respond with the cookie.

MaxAge

The maximum age of the cookie in seconds. After this number of seconds has elapsed, the cookie expires. Zero deletes the cookie. A negative number or blank value indicates the cookie is not persistent and will be deleted when the browser exits.

Secure

Values of true, yes, or 1 indicate that the cookie should not be sent unless a secure protocol, such as HTTPS, is used. Evaluation of the value of this parameter is not case-sensitive.

You must supply a non-empty value for the Name and Value parameters, but you can omit values for the other parameters. Empty values must be represented with double quote characters.

Because headers and cookies must be sent before any data, the COOKIE keyword must precede any data in the template, including spaces, tabs, carriage returns, and line feeds. The easiest way to ensure that no data is sent before the COOKIE keyword is processed is to include the NOOUTPUT keyword as the very first item in the template, followed by the COOKIE keyword and the OUTPUT keyword, as shown in the following example:

{NOOUTPUT}
{COOKIE "user-id" "jsmith"  ""  ""  ""  ""}
{OUTPUT}
. . .

For more information about the NOOUTPUT and OUTPUT keywords, see Section 4.11, NOOUTPUT and Section 4.12, OUTPUT.