Main Content

matlab.net.http.CookieInfo Class

Namespace: matlab.net.http

HTTP cookie information

Description

The CookieInfo class contains a Cookie object and information about the cookie that you can use for cookie management. To obtain a CookieInfo object, call the convert method of a SetCookieField object in a response message.

Unlike browsers, MATLAB® does not provide an automatic cookie store. You must save cookies on your own and send them back to servers as needed.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

Description

obj = matlab.net.http.CookieInfo(Name,Value) creates a CookieInfo object with additional properties specified by one, or more name-value pair arguments. Name is the property name and Value is the corresponding value. You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN. Unspecified properties are set to their default values.

Use this constructor for testing.

Properties

expand all

Cookie, specified as a matlab.net.http.Cookie object. Insert the Cookie into a request message CookieField property.

Attributes:

GetAccess
public
SetAccess
public

Cookie expiration time, specified as a datetime object. If there is an Expires attribute in the header field, then the Expires property is set. If the Expires attribute cannot be parsed, then Expires is NaT.

Attributes:

GetAccess
public
SetAccess
public

Data Types: datetime

Duration of cookie, specified as an integer or NaN. If there is a Max-Age attribute in the header field, then the MaxAge property is set. If the Max-Age attribute cannot be parsed, then MaxAge is NaN.

Attributes:

GetAccess
public
SetAccess
public

Cookie domain, specified as a string. If the Set-Cookie field does not specify a Domain attribute, then the Domain property is set to the request message URI.Host property and HostOnly is set to true. Domain never begins with a period, as described in RFC 6265 HTTP State Management Mechanism, Section 5.2.3 on the RFC Editor website.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string

Path attribute in a Set-Cookie field, specified as a string. The Path property is the value of the Path attribute in the Set-Cookie field. If the field does not contain a path attribute, then the Path property is set to default-path based on the request message URI.Path property. For a description of default-path, see RFC 6265 HTTP State Management Mechanism, Section 5.1.4. Paths and Path-Match. Path always begins with a slash (/) character.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string

Secure attribute status, where the Secure property is specified as true or false. The Secure property indicates that the Set-Cookie field contains a Secure attribute.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

HttpOnly attribute status, where the HttpOnly property is specified as true or false. The HttpOnly property indicates that the Set-Cookie field contains an HttpOnly attribute.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Values of extension-av attributes, specified as a string. The entire attribute is a single string, even if its syntax is of the form name=value.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string

Domain attribute status, where the HostOnly property is specified as true or false. If the Set-Cookie field contains a Domain attribute, then HostOnly is true.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Cookie expiration, specified as a datetime object.

  • If the Set-Cookie field contains either an Expires or a Max-Age attribute, then ExpirationTime is set to the attribute.

  • If neither attribute appears, then ExpirationTime is set to datetime('Inf') and the cookie is retained until the current session is over.

Attributes:

GetAccess
public
SetAccess
public

Data Types: datetime

Time the cookie was created, specified as a datetime object. The SetCookieField.convert method sets CreationTime to the current time.

If a new CookieInfo object matches an existing one, then the new object replaces the old one. However, the CreationTime property does not change. This behavior is specified in RFC 6265 HTTP State Management Mechanism, Section 5.3 Storage Model, step 11.3. The CookieInfo objects match when the Cookie.Name, CookieInfo.Domain, and CookieInfo.Path (if specified) properties are equal.

Attributes:

GetAccess
public
SetAccess
public

Data Types: datetime

Methods

expand all

Version History

Introduced in R2016b