Search code examples
javahtmlunit

How to make 2 HtmlUnit's WebClients use same cookies?


If I create 2 WebClients in different threads, how do I make them use the same cookies?


Solution

  • You can use the below code:

    CookieManager cookieManager = new CookieManager();
    webClient1.setCookieManager(cookieManager);
    webClient2.setCookieManager(cookieManager);