Skip to content

//okhttp/okhttp3/CookieJar

CookieJar

[jvm]\ interface CookieJar

Provides policy and persistence for HTTP cookies.

As policy, implementations of this interface are responsible for selecting which cookies to accept and which to reject. A reasonable policy is to reject all cookies, though that may interfere with session-based authentication schemes that require cookies.

As persistence, implementations of this interface must also provide storage of cookies. Simple implementations may store cookies in memory; sophisticated ones may use the file system or database to hold accepted cookies. The cookie storage model specifies policies for updating and expiring cookies.

Types

Name Summary
Companion [jvm]
object Companion

Functions

Name Summary
loadForRequest [jvm]
abstract fun loadForRequest(url: HttpUrl): List<Cookie>
Load cookies from the jar for an HTTP request to url. This method returns a possibly empty list of cookies for the network request.
saveFromResponse [jvm]
abstract fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>)
Saves cookies from an HTTP response to this store according to this jar’s policy.