List of utility methods to do Cookie
String | getCookies(final URL url) Returns the cookies returned by the server on accessing the URL. final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.setAllowUserInteraction(false); urlConn.setDoInput(true); urlConn.setDoOutput(false); urlConn.setUseCaches(false); urlConn.setRequestProperty(USER_AGENT_HEADER_NAME, USER_AGENT_PROPERTY_VALUE); urlConn.connect(); final List<String> cookies = urlConn.getHeaderFields().get("Set-Cookie"); ... |
void | storeCookies(HttpURLConnection connection) store Cookies Map<String, List<String>> headers = connection.getHeaderFields(); List<String> cookies = headers.get("Set-Cookie"); if (cookies != null) { for (String cookie : cookies) { cookieManager.getCookieStore().add(null, HttpCookie.parse(cookie).get(0)); |