Estimated reading time: 1 minute

This feature keeps cookies between calls or forces specific cookies.

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


val client = HttpClient() {
    install(HttpCookies) {
        // Will keep an in-memory map with all the cookies from previous requests.
        storage = AcceptAllCookiesStorage()

        // Will ignore Set-Cookie and will send the specified cookies.
        storage = ConstantCookieStorage(Cookie("mycookie1", "value"), Cookie("mycookie2", "value"))