Skip to main content

Inserting, Listing, and Deleting Cookies

Inserting, Listing, and Deleting Cookies

%Net.HttpRequestOpens in a new tab automatically manages cookies sent from the server; if the server sends a cookie, your instance of %Net.HttpRequestOpens in a new tab will return this cookie on the next request. (For this mechanism to work, you need to reuse the same instance of %Net.HttpRequestOpens in a new tab.)

Use the following methods to manage cookies within your instance of %Net.HttpRequestOpens in a new tab:

InsertCookie()
method InsertCookie(name As %String, 
                    value As %String, 
                    path As %String, 
                    domain As %String, 
                    expires As %String, 
                    secure As %Boolean = 0) as %Status

Inserts a cookie into the request. Specify the following arguments:

  • name is the name of the cookie.

  • value is the value of the cookie.

  • path is the path where the cookie should be stored.

  • domain is the name of the machine from which to download the cookie.

  • expires is the date and time when the cookie expires.

  • secure is 1 if the cookie should be sent only over secure channels.

InsertCookieList()

Iterates through a multidimensional array that contains cookies and inserts each one into the request. The format of the array is as follows:

array(index)=$LB(name,domain,path,value,expires,secure)
GetFullCookieList()
method GetFullCookieList(ByRef cookies) as %Integer

Returns the number of cookies and returns (by reference) an array of cookies.

DeleteCookie()
method DeleteCookie(name As %String, path As %String, domain As %String) as %Status

Deletes a cookie from the request. The name, path, and domain must match the ones used to insert the cookie in the first place.

Remember that cookies are specific to an HTTP server. When you insert a cookie, you are using a connection to a specific server, and the cookie is not available on other servers.

FeedbackOpens in a new tab