How to handle cookies in httpUrlConnection using cookieManager

Ok, the right way to do it is just like that: Get Cookies from response header and load them into cookieManager: static final String COOKIES_HEADER = “Set-Cookie”; HttpURLConnection connection = … ; static java.net.CookieManager msCookieManager = new java.net.CookieManager(); Map<String, List<String>> headerFields = connection.getHeaderFields(); List<String> cookiesHeader = headerFields.get(COOKIES_HEADER); if (cookiesHeader != null) { for (String cookie … Read more