okhttp / okhttp3 / Cookie


class Cookie

An RFC 6265 Cookie.

This class doesn’t support additional attributes on cookies, like Chromium’s Priority=HIGH extension.


Name Summary
Builder Builds a cookie. The name, value, and domain values must all be set before calling build.class Builder


Name Summary
domain Returns the cookie’s domain. If hostOnly returns true this is the only domain that matches this cookie; otherwise it matches this domain and all subdomains.val domain:String
expiresAt Returns the time that this cookie expires, in the same format as System.currentTimeMillis. This is December 31, 9999 if the cookie is persistent, in which case it will expire at the end of the current session.val expiresAt:Long
hostOnly Returns true if this cookie’s domain should be interpreted as a single host name, or false if it should be interpreted as a pattern. This flag will be false if its Set-Cookie header included a domain attribute.val hostOnly:Boolean
httpOnly Returns true if this cookie should be limited to only HTTP APIs. In web browsers this prevents the cookie from being accessible to scripts.val httpOnly:Boolean
name Returns a non-empty string with this cookie’s name.val name:String
path Returns this cookie’s path. This cookie matches URLs prefixed with path segments that match this path’s segments. For example, if this path is /foo this cookie matches requests to /foo and /foo/bar, but not / or /football.val path:String
persistent Returns true if this cookie does not expire at the end of the current session.val persistent:Boolean
secure Returns true if this cookie should be limited to only HTTPS requests.val secure:Boolean
value Returns a possibly-empty string with this cookie’s value.val value:String


Name Summary
equals fun equals(other:Any?):Boolean
hashCode fun hashCode():Int
matches Returns true if this cookie should be included on a request to url. In addition to this check callers should also confirm that this cookie has not expired.fun matches(url:HttpUrl):Boolean
toString fun toString():String

Companion Object Functions

Name Summary
parse Attempt to parse a Set-Cookie HTTP header value setCookie as a cookie. Returns null if setCookie is not a well-formed cookie.fun parse(url:HttpUrl, setCookie:String):Cookie?
parseAll Returns all of the cookies from a set of HTTP response headers.fun parseAll(url:HttpUrl, headers:Headers):List<Cookie>