HTTP cookie received from server
Cookie class represents an HTTP cookie. You
Cookie object from a
ResponseMessage object. Then you send it back
to the server in a
Name— Cookie name (read-only)
Cookie name, specified as a string.
Value— Cookie value (read-only)
Cookie value, specified as a string. The value only has meaning to the server that sent the cookie.
These methods implement the equivalent MATLAB® functionality for this class.
Cookie as character vector
Cookie as string
This example assumes a server returns specific
values in the variable
response. You cannot run
this code in MATLAB. You can, however, use these coding patterns
to test values from your web service responses.
Create a cookie object
values you expect from a server.
test = matlab.net.http.Cookie('cookie1','ID:33445566')
test = Cookie with properties: Name: "cookie1" Value: "ID:33445566"
Send a message to a server; this step is not shown in
the example. Assume that the server responds to your request message
with the following information in the
setCookieFields = response.getFields('Set-Cookie')
setCookieFields = SetCookieField with properties: Name: "Set-Cookie" Value: "cookie1=ID:33445566; Path=/"
Extract the cookie information.
cookieInfos = setCookieFields.convert;
Compare the cookie with your test cookie.
string(cookieInfos.Cookie) == string(test)
ans = 1
The cookies match.