Skip to content

//okhttp/okhttp3/Cookie

Cookie

[jvm]\ class Cookie

An RFC 6265 Cookie.

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

Types

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

Functions

Name Summary
equals [jvm]
open operator override fun equals(other: Any?): Boolean
hashCode [jvm]
@IgnoreJRERequirement
open override fun hashCode(): Int
matches [jvm]
fun matches(url: HttpUrl): Boolean
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.
newBuilder [jvm]
fun newBuilder(): Cookie.Builder
toString [jvm]
open override fun toString(): String

Properties

Name Summary
domain [jvm]
@get:JvmName(name = "domain")
val domain: String
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.
expiresAt [jvm]
@get:JvmName(name = "expiresAt")
val expiresAt: Long
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.
hostOnly [jvm]
@get:JvmName(name = "hostOnly")
val hostOnly: Boolean
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.
httpOnly [jvm]
@get:JvmName(name = "httpOnly")
val httpOnly: Boolean
Returns true if this cookie should be limited to only HTTP APIs. In web browsers this prevents the cookie from being accessible to scripts.
name [jvm]
@get:JvmName(name = "name")
val name: String
Returns a non-empty string with this cookie’s name.
path [jvm]
@get:JvmName(name = "path")
val path: String
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.
persistent [jvm]
@get:JvmName(name = "persistent")
val persistent: Boolean
Returns true if this cookie does not expire at the end of the current session.
secure [jvm]
@get:JvmName(name = "secure")
val secure: Boolean
Returns true if this cookie should be limited to only HTTPS requests.
value [jvm]
@get:JvmName(name = "value")
val value: String
Returns a possibly-empty string with this cookie’s value.