title: How to handle cookies in httpUrlConnection using cookieManager
body: <p>I have a server request that returns multiple cookies, like that:</p>
  <p><img src="https://i.stack.imgur.com/g7Uit.png" alt="enter image description here" /></p>
  <p>This is how I'm storing these cookies to the cookieManager:</p>
  <pre><code>HttpURLConnection connection = ... ;
  static java.net.CookieManager msCookieManager = new java.net.CookieManager();
  msCookieManager.put(COOKIES_URI, connection.getHeaderFields());
  </code></pre>
  <p>This is how I'm adding these cookies to the next connection:</p>
  <pre><code>connection.setRequestProperty(&quot;Cookie&quot;, 
    msCookieManager.getCookieStore().get(COOKIES_URI).toString());
  </code></pre>
  <p>Is it the right way to get the cookies from the cookieManager?,
  I'm quite sure there is a better one...</p>