How to get cookies with Java?
You can either get the cookies from the header,
or you can use Apache commons and use their functionality.
You can use java.net.URLConnection
for this. It offers a getHeaderFields()
method to get the response headers. The cookies are set by Set-Cookie
header.
URLConnection connection = new URL("http://google.com").openConnection();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
// ...