Cookies

This feature keeps cookies between calls or forces specific cookies.

This feature is defined in the method io.ktor.client.features.cookies and no additional artifacts are required.

Installation

  1. val client = HttpClient() {
  2. install(HttpCookies) {
  3. // Will keep an in-memory map with all the cookies from previous requests.
  4. storage = AcceptAllCookiesStorage()
  5. // Will ignore Set-Cookie and will send the specified cookies.
  6. storage = ConstantCookieStorage(Cookie("mycookie1", "value"), Cookie("mycookie2", "value"))
  7. }
  8. }
  9. client.cookies("mydomain.com")