How to set Cookies at Http Get method using Java

To be sure, you should be gathering the cookies from the response’s Set-Cookie headers. To send them back in the subsequent requests, you should set them one by one using URLConnection#addRequestProperty(). Basically: // … // Grab Set-Cookie headers: List<String> cookies = connection.getHeaderFields().get(“Set-Cookie”); // … // Send them back in subsequent requests: for (String cookie : … Read more