Web Cookies

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 http://en.wikipedia.org/wiki/HTTP_cookie).

### 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 http://www.ietf.org/rfc/rfc2965.txt, 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

- cgitest -- tests a CGI procedure.
- closeserverfile -- closes the current database (used on the server).
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- info("httprequestinprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- info("webclientsessioninprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- openserverfile -- opens a database (used on the server).
- serverrunning( -- returns true if this code is running on a Panorama server, or false if it is running in single user mode or on a client.
- serverstatus( -- returns a dictionary describing the current status of Panorama X Server.
- setcookie -- set the value of a cookie to send back to the client..
- URL Tool Menu (Web Debugging) -- tool with popup menu to assist with debugging web procedures.
- urlfilename( -- extracts the filename from a complete url.
- urlpath( -- extracts the path from a URL.
- Web Error Pages -- customizing the server response when an error occurs.
- webformitemvalue( -- gets the value of a POST web form item (used when processing a web query with Panorama Server).
- webhomesubfolder( -- returns the folder ID of a subfolder of the web server's home folder.
- webimagedisplay( -- used within an Image Display Object to specify both a web image (used when the form is displayed in a web browser from Panorama Server) and a local image file (used when the form is displayed within Panorama).
- webserverinfo( -- retrieves additional information about the web server and the current browser request.
- webshare -- perform record locking operations from a web publishing procedure.
- webtagortext( -- prepares text for display in a web page.
- webtext( -- converts a number or regular text into text encoded for display in a web browser.

History

Version | Status | Notes
10.2 | New | New in this version.