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); }
Array ( ) One Response to “How do I get the cookies from a HTTP connection?”
Leave a Reply
You must be logged in to post a comment.
August 19th, 2013 at 8:34 am
Muy buena información, me sirvió mucho.