An HTTP cookie, or a Web cookie (also called simply a cookie), is a parcel of text sent by a server to a web browser and then sent back unchanged by the browser each time it accesses that server. HTTP cookies are used for authenticating, tracking, and maintaining specific information about users, such as site preferences and the contents of their electronic shopping carts. Without cookies, each retrieval of a web page or component of a web page is an isolated event, mostly unrelated to all other views of the pages of the same site. By returning a cookie to a web server, the browser provides the server a means of connecting the current page view with prior page views. (This paragraph was adapted from material found on Wikipedia. You can find a lot more at

Cookie Name and Value

A cookie has a name and a value. The name is used to identify the cookie, the value is the actual contents. This is similar to a field or variable, which also have a name and a value.

Cookie names can only contain ASCII letters (A thru Z) and numbers. Spaces, punctuation and unicode characters are not allowed. So names like SalesTax or AccountID are fine, but Sales Tax and Account ID are invalid.

Cookie names are not case sensitive, so SalesTax, SALESTAX and salestax all refer to the same cookie value.

Creating a Cookie

To create a cookie use the setcookie statement, which has four parameters:

setcookie name,value,expiration,options

The last two parameters are optional, but the first two are required. The first parameter is the name of the cookie. This must contain only letters and numbers. The second parameter is the value of the cookie. Here are some examples of how to create cookies:

setcookie "SalesTax","8.25"
setcookie "TableFontPref","Verdana"
setcookie "MyAreaCode","858"

Cookie Expiration Date

Cookies don’t last forever. In fact, if you don’t specify an expiration date for a cookie then it will disappear when the user closes the browser window. If you want to keep a cookie around for a while set an expiration date for it, like this:

setcookie "SalesTax","8.25","12 hours"
setcookie "TableFontPref","Verdana","12 weeks"
setcookie "MyAreaCode","858","12 years"

The cookie expiration time can be speified in seconds, minutes, days, weeks, months or years.

Cookie Options

This optional parameter allows you to add more options to the cookie. The best source of information we’ve found for additional cookie options is at, however, please note that the Panorama Server uses the original cookie format, not version 2 (it appears that the version of Apache shipped with MacOS does not support version 2 cookies). In general you probably don’t need to worry about these extra options.

Retrieving a Cookie Value

To get the value of a previously stored cookie use the getcookie( function. This function has one parameter, the name of the cookie. Here are some examples.

let salestax = val(getcookie("SalesTax"))
let tablefont = getcookie("TableFontPref")
let phoneareacode = getcookie("MyAreaCode")

Listing Cookies

The getcookielist( function gets a list of all cookies that have been stored by this server. It has no parameters.

let myCookies = getcookielist()

See Also


10.2NewNew in this version.