Get http request cookies [closed]

1

Good afternoon, I'm having trouble catching cookies when I make an HTTP request for a given address. Using firefox + firebug I display 5 cookies. Already through my program in Java I can only see 1 of them.

follow the program code:

public static void getCookieUsingCookieManager(String urlS) {
    try {
        CookieManager manager = new CookieManager();
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(manager);

        URL url = new URL(urlS);
        URLConnection connection = url.openConnection();

        connection.getContent();

        CookieStore cookieJar = manager.getCookieStore();
        List<HttpCookie> cookies
                = cookieJar.getCookies();
        for (HttpCookie cookie : cookies) {
            System.out.println("CookieHandler retrieved cookie: " + cookie.toString());
        }
    } catch (Exception e) {
        System.out.println("Unable to get cookie using CookieHandler");
        e.printStackTrace();
    }
}
    
asked by anonymous 01.12.2014 / 18:35

0 answers