Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

matlab.net.http.CookieInfo class

Package: 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.

Construction

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 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Data Types: datetime

Methods

collectFromLogLatest CookieInfo objects from HTTP response message history

These methods implement the equivalent MATLAB functionality for this class.

char

Cookie info as character vector

string

Cookie info as string

Attributes

Sealedtrue

Introduced in R2016b

Was this topic helpful?