This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

matlab.net.http.field.SetCookieField class

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

HTTP Set-Cookie header field

Description

A SetCookieField object appears in a response message created by the server. A message can have one or more Set-Cookie fields. To extract the Value property as a CookieInfo object, call the convert method.

Class Attributes

Sealed

true

For information on class attributes, see Class Attributes.

Properties

expand all

Header field name, specified as 'Set-Cookie'.

Attributes:

GetAccess

public

SetAccess

public

Header field value, specified as a string.

Attributes:

GetAccess

public

SetAccess

public

Methods

expand all

Examples

collapse all

r = matlab.net.http.RequestMessage();
uri = matlab.net.URI('http://httpbin.org/cookies/set?xxx=zzz&abc=def');
opts = matlab.net.http.HTTPOptions('MaxRedirects',0);
resp = r.send(uri,opts);
setCookieFields = resp.getFields('Set-Cookie');
if ~isempty(setCookieFields)
   cookieInfos = setCookieFields.convert(uri);
   r = r.addFields(matlab.net.http.field.CookieField([cookieInfos.Cookie]));
end
resp = r.send('http://httpbin.org/cookies');
disp(resp.Body.Data.cookies)
    abc: 'def'
    xxx: 'zzz'

Introduced in R2016b