TWebCookies
TWebCookies
is a collection class for managing cookies in your web application. It is defined in
the unit WEBLib.Cookies
. This is a collection of TWebCookie
items. The TWebCookie
item has
following properties:
Property | Description |
---|---|
property Name:string; | gets or sets the cookie name/identifier |
property Value:string; | gets or sets the cookie value |
property Expiry:TDateTime; | gets or sets the cookie expiry date |
property Path | gets or sets the cookie path |
The path parameter specifies a document location for the cookie, so it’s assigned to a specific path, and sent to the server only if the path matches the current document location, or a parent:
To get the browser cookies for the application URL in the TWebCookies collection call
TWebCookies.GetCookies
.
For updating the cookies in the browser after making changes to the collection TWebCookie
items, call TWebCookies.SetCookies
.
Other TWebCookies collection methods:
Method | Description |
---|---|
procedure Delete(ACookie: TCookie); | Delete a cookie by instance |
procedure Delete(const AName: string); | Delete a cookie by name |
Methods |
---|
function Add(const AName, AValue: string; Expiry: TDateTime): TCookie; |
function Add(const AName, AValue: string): TCookie; |
function Add(const AName, AValue, APath: string): TCookie; |
function Add(const AName, AValue, APath: string; Expiry: TDateTime): TCookie; |
Four different overload functions that allow to a add a new cookie to the TWebCookies collection.
Property | Description |
---|---|
property Items[Index: integer]: TCookie; | Property providing access to each cookie in the collection by an array indexer |
function Find(const AName: string): TCookie; | Find a cookie instance by name in the collection |