Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
WebSpeed API Reference : set-cookie
 

set-cookie

This function sets a persistent state cookie in the Web browser by outputting an HTTP Set-Cookie header with specified options. The Web browser on future requests sends the name and associated value of the cookie automatically. This is especially useful for preserving state information between requests.

Location

web\method\cookies.i

Parameters

INPUT p_name AS CHARACTER
The name of the cookie.
INPUT p_value AS CHARACTER
The value of the cookie.
INPUT p_date AS DATE
The optional expiration date (local). If the Unknown value (?) is specified, the cookie expires when the browser session ends.
INPUT p_time AS INTEGER
The optional expiration time (local) as a number of seconds since midnight. This parameter only has meaning if p_date is not the Unknown value (?). If you do not want to set a specific time, specify the Unknown value (?).
INPUT p_path AS CHARACTER
The URL path to which the cookie should apply. If Unknown value (?) is specified, the value of the DefaultCookiePath configuration option is used or, if that is not set, the value of the AppURL global variable.
INPUT p_domain AS CHARACTER
The optional domain to which the cookie should apply. If Unknown value (?) is specified, value of the DefaultCookieDomain configuration option is used or, if that is not set, the domain option is not set on the cookie. In that case, the current hostname of the Web server is used by the Web browser.
INPUT p_options AS CHARACTER
A comma-delimited list of options. The valid values are as follows:
*Secure — If specified, the Web browser only sends the Cookie back when on a secure (SSL) connection (using HTTPS).
*Local — (Default) Assume date and time are based on local time and need conversion to UTC.
*UTC — Assume date and time are UTC based eliminating any conversion that would otherwise be required from local time to UTC time.

Returns

CHARACTER

Notes

*If the p_time expression is a very large or small number (greater or less than the number of seconds in a day), it is normalized to fit within a day. In this case, the expiration date is incremented or decremented as appropriate.
*Because of possible differences between the user's machine and your server's clocks, cookies based on functions like TIME might not expire exactly when you expect them to expire.
*Requires a browser supporting persistent state cookies. Other browsers should ignore the HTTP Set-Cookie header.
*Cookies must be set within the HTML header. Therefore, for all practical purposes, all cookies must be defined prior to the first call to the output-content-type function.
*Before using cookies, you should read the standards published for the various Web servers.

Examples

\* Sets cust-num = 23 *\
set-cookie("cust-num":U, "23":U, ?, ?, ?, ?, ?).

\* Set USER-ID valid in or below the current web object with an expiration time
of one week from today. *\
set-cookie("UserId":U, USER-ID, TODAY + 7, ?, ?, ?, ?).

See also

output-content-type
delete-cookie
get-cookie
delete-cookie