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.field.CookieField class

Package: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField

HTTP Cookie header field

Description

If there are cookies in a Set-Cookie field, then you can send them to a server by including a CookieField object in your request message. For more information, see RFC 6265 HTTP State Management Mechanism.

Construction

example

obj = matlab.net.http.field.CookieField(value) creates a Cookie header field with the Value property set to value.

Properties

expand all

Header field name, specified as 'Cookie'.

Cookie, specified as a string.

Methods

convert

All Cookie objects in CookieField

Attributes

Sealedtrue

Examples

expand all

This example sends all cookies to a server. In practice, you would send only unexpired cookies.

If the initial exchange involves multiple messages for authentication and redirection, you might want to obtain the CookieInfo object from the history containing all these messages. For more information, see CookieInfo.collectFromLog.

r = matlab.net.http.RequestMessage;
resp = send(r,'http://www.mathworks.com');
setCookieFields = resp.getFields('Set-Cookie');
if ~isempty(setCookieFields)
   % fetch all CookieInfos from Set-Cookie fields and add to request
   cookieInfos = setCookieFields.convert;
   r = r.addFields(matlab.net.http.field.CookieField([cookieInfos.Cookie]));
end
resp = r.send('http://www.mathworks.com');

Introduced in R2016b

Was this topic helpful?