Main Content

matlab.net.http.field.SetCookieField Class

Namespace: 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
Dependent
true

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'

Version History

Introduced in R2016b