Oct 01

Cookies are specified in the response header keyed on ‘Set-Cookie’ so the getHeaderFields() method of URLConnection can be used to retrieve them.


URLConnection conn = new url.openConnection();
Map<String,List<String>> headers = conn.getHeaderFields();
List<String> cookies = headers.get("Set-Cookie");
for (String cookie: cookies)
{
   System.out.println(cookie);
} 

written by objects \\ tags: ,


One Response to “How do I get the cookies from a HTTP connection?”

  1. JUAN CARLOS PEÑA MORENO Says:

    Muy buena información, me sirvió mucho.

Leave a Reply

You must be logged in to post a comment.