Java: Automatic cookie handling in HttpClient?
-
16-09-2019 - |
Question
In Java HttpClient feature list it says:
Automatic Cookie handling for reading Set-Cookie: headers from the server and sending them back out in a Cookie: header when appropriate.
But I can't figure out how to use this feature. I just need to open a web page, let it set all the cookies, then refresh the same page with received cookies.
Thanks.
Solution
I kept getting errors back from the server saying my client didn't support cookies and I should turn them on. The following line stopped those errors. Hope this works for you.
httpClient.setCookieStore(new BasicCookieStore());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow