Cookie management with API

  • Created

We recommend that you read the Getting started with Kameleo Automation article before reading this one.

Accessing cookies to export them to a .json file or importing cookies from another system to a Kameleo virtual browser profile can be useful. You won’t have to deal with different browser APIs you can simply use Kameleo Local API to do it.

You can export, import, or delete cookies of any virtual browser profile that is in terminated state. So it has been started at least once, but currently not running.

In this example we show how to list cookies, then modify a cookie and then delete all cookies.

Adding a cookie for a domain will override all the cookies for the given domain.

  • const cookieList = await client.listCookies(;
    const newCookie = cookieList[0];
    newCookie.value = '123';
    const cookiesArray = new Array(newCookie);
    await client.addCookies(, { body: cookiesArray });
    await client.deleteCookies(;

    See full example here.

  • var cookieList = await client.ListCookiesAsync(profile.Id);
    var newCookie = cookieList[0];
    newCookie.Value = "123";
    var cookiesArray = new List<CookieRequest> {new CookieRequest(newCookie)};
    await client.AddCookiesAsync(profile.Id, cookiesArray);
    await client.DeleteCookiesAsync(profile.Id);

    See full example here.

  • cookie_list = client.list_cookies(
    cookie = cookie_list[0]
    new_cookie = CookieRequest(domain=cookie.domain,, path=cookie.path, value=cookie.value,
        host_only=cookie.host_only, http_only=cookie.http_only,,
        same_site=cookie.same_site, expiration_date=cookie.expiration_date)
    cookie_array = [new_cookie]
    client.add_cookies(, body=cookie_array)

    See full example here.

Was this article helpful?

0 out of 1 found this helpful