Indy 9
TIdNetscapeCookie
Hierarchy, Properties, Methods, See Also, Unit: IdCookie
Implements a persistent state mechanism for HTTP connections using Cookies.
TIdNetscapeCookie = class(TCollectionItem)
Unit
IdCookie
Description
TIdNetscapeCookie is a TCollectionItem descendant that implements a persistent state mechanism used to store and retrieve about HTTP client connections using Cookies, as described in the reference document:

  • Netscape Persistent Client State - HTTP Cookies (http://www.netscape.com/newsref/std/cookie_spec.html)

TIdNetscapeCookie provides methods and properties to allow introduction of one or more Cookie values and associated Cookie attributes to the client as part of an HTTP response, including the common Cookie headers Name, Value, Domain, Path, and Secure.

TIdNetscapeCookie also implements the Expires header to let the client know when it is safe to purge Cookie data.

TIdNetscapeCookie can also be used to represent Cookie values returned from a client to an HTTP Server.

TIdNetscapeCookie is used as the ancestor for descendant classes that implement alternate Cookie representations, including TIdCookie2109 and TIdCookie2965.


TIdNetscapeCookie.ClientCookie
TIdNetscapeCookie, See Also
Represents the Cookie name and value.
property ClientCookie: String;
Return Value
String - Name and value for the Cookie.
Description
ClientCookie is a read-only String property that represents the CookieName and Value for the Cookie. ClientCookie returns the property values in the form NAME=VALUE. Use ServerCookie or CookieText to access the Cookie including attributes values like Domain, Path, Secure, and Expires.

TIdNetscapeCookie.CookieName
TIdNetscapeCookie, See Also
Represents the identity for a Cookie header.
property CookieName: String;
Description
CookieName is a String property that contains the identity portion of the name/value attribute pair that represents the Client or Server Cookie. CookieName is used to access the textual content of the Cookie in a TIdCookies collection.

CookieNames that begin with $ are reserved for specifiying attributes to associate with an adjacent cookie, and must not be used by applications.


TIdNetscapeCookie.CookieText
TIdNetscapeCookie, See Also
Represents the textual representation for a Cookie including attribute parameters.
property CookieText: String;
Description
CookieText is a String property that represents the name and value attribute pair, as well as optional parameters that make up the textual representaion of the Cookie. CookieText can contain the in the CookieName and Value properties, as well as property values from Expires, Path, Domain, and the Secure flag.

Use ServerCookie to access the Set-Cookie variant of the Cookie for use in an HTTP response. Use ClientCookie to access the values as received on an HTTP Client.


TIdNetscapeCookie.Domain
TIdNetscapeCookie, See Also
Indicates the host system where a Cookie is valid.
property Domain: String;
Description
Domain is a String property that represents the optional Cookie attribute that specifies the host system where the Cookie is valid. Domain can contain an explicit value, beginning with a '.', or the value of the host that receives the request.

Domain is used in IsValidCookie to determine if a specific Cookie can be used for the server host in an HTTP request.

Use Path to determine the subset of URLs where a Cookie is valid.


TIdNetscapeCookie.Expires
TIdNetscapeCookie, See Also
Indicates the life time of the Cookie.
property Expires: String;
Description
Expires is a String property that represents the optional Cookie attribute that defines the valid life time of a Cookie. Once the expiration date has been reached, the cookie will no longer be stored or given out. Expires is expressed in a format based on RFC 822, RFC 850, RFC 1036, and RFC 1123, with the variations that the only legal time zone is GMT and the separators between the elements of the date must be dashes. For example:

    Wed, 04-Jul-2001 01:00:01 GMT

When Expires is omitted, the Cookie will expire when the HTTP session ends.

Note: There is a bug in Netscape Navigator version 1.1 and earlier. Only Cookies whose Path attribute is set explicitly to "/" will be properly saved between sessions if they have an Expires attribute value.


TIdNetscapeCookie.Path
TIdNetscapeCookie, See Also
Specifies the subset of URLs valid for the Cookie.
property Path: String;
Description
Path is a String property that specifies the subset of URLs in a Domain for which the Cookie is valid. If the Domain for a Cookie matches the server host, then the request path specified in a URL is compared with the Path attribute, and is considered valid when Path is a subset of the request URL.

TIdNetscapeCookie.Secure
TIdNetscapeCookie
Indicates the Cookie requires a secure communications channel.
property Secure: Boolean;
Description
Secure is a Boolean property that indicates the Cookie can be transmitted only on a secure communications channel. Currently this means that secure cookies will only be sent to HTTPS (HTTP over SSL) servers. If secure is not specified, a cookie is considered safe to be sent in the clear over unsecured channels.

TIdNetscapeCookie.ServerCookie
TIdNetscapeCookie, See Also
Represents the Cookie contents in a Server response.
property ServerCookie: String;
Description
ServerCookie is a read-only String property that represents the textual representation of the Cookie name value pair and optional attributes, like CookieText. ServerCookie is used to provide persistent state information from an HTTP Server to an HTTP client.

Use ClientCookie to provide information about a persistent session as part of an HTTP client request.

Use CookieText to access Cookie properties when updates can be performed.


TIdNetscapeCookie.Value
TIdNetscapeCookie, See Also
Represents persistent state data associated with a Cookie name.
property Value: String;
Description
Value is a String property that represents the persistent state data associated with the identity in CookieName. Value is used to construct CookieText, with optional attribute values, that represents the complete Cookie.

TIdNetscapeCookie.Assign
TIdNetscapeCookie, See Also
Copies property values to the current object instance.
procedure Assign(Source: TPersistent); override;
Parameters
Source: TPersistent
Persistent class containing values to be copied.
Description
Assign is a procedure used to copy and assign values from a TPersistent descendant in Source to the current object instance. When Source is a TIdCookieRFC2109 class instance, Assign updates CookieText and the internal Cookie version using the property values in Source.

TIdNetscapeCookie.Create
TIdNetscapeCookie, See Also
Constructor for the object instance.
constructor Create(ACollection: TCollection); override;
Parameters
ACollection: TCollection
Collection that owns the collection item.
Description
Create is the constructor for the object instance, and calls the inherited Create method using the Cookie collection specified in ACollection as the owner of the Cookie. Create sets the internal version for the Cookie to cvNetscape prior to exiting from the method.

TIdNetscapeCookie.Destroy
TIdNetscapeCookie, See Also
Frees the collection item.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance, and insures that all Cookie values for the curent Domain are removed from the in the TIdCookies Collection. Destroy calls the inherited Destroy prior to exiting the method.

TIdNetscapeCookie.IsValidCookie
TIdNetscapeCookie, See Also
Indicates if the Domain for the Cookie matches the host server for the request.
function IsValidCookie(AServerHost: String): Boolean; virtual;
Parameters
AServerHost: String
Host server receiving the request.
Return Value
Boolean - True when the host server matches Domain.
Description
IsValidCookie is a Boolean function that indicates if the Domain for the Cookie matches the host server that received the request and state information. AServerHost is the server that received the request containing the persistent state information in the Cookie. IsValidCookie returns True when AServerHost contains an IP address or host name that matches the Domain for the Cookie.

Use Path to determine the subset of URLs where the Cookie is valid.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.