Manage Cookies
The HTTP interface provides classes for you to manage cookies in HTTP messages. For information about cookies, see RFC 6265 HTTP State Management Mechanism on the RFC Editor website.
The Cookie
class contains the name and value of the cookie. For
example, display the properties of a Cookie
object
C
.
C = Cookie with properties: Name: "JSESSIONID" Value: "688412d8ed1cdf15f4a736dc6ab3"
The CookieInfo
class contains the cookie and its attributes. The
attributes are the properties of the CookieInfo
object. For example,
info
is a CookieInfo
object containing cookie
C
.
class(info)
ans = matlab.net.http.CookieInfo
Display attributes of the cookie.
info.Expires
ans = Sun, 26 Mar 2084 17:15:30 GMT
info.CreationTime
ans = Tue, 07 Jun 2016 09:38:56 GMT
A server returns cookies in a response message using a SetCookieField
object. To get a CookieInfo
object, call the
SetCookieField.convert
method.
To send a cookie to the server, add a CookieField
object to a request
message.