I want to get all cookies from a website using Java In cookie have:
_ga_gidPHPSESSID
I tried this code, but it just gave only PHPSESSID.
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
URL url = new URL("https://example.com/");
URLConnection connection = url.openConnection();
connection.getContent();
List<HttpCookie> cookies = cookieManager.getCookieStore().getCookies();
for (HttpCookie cookie : cookies) {
System.out.println(cookie.getDomain());
System.out.println(cookie);
}
How can I solve this?