code: private void saveResponseCookies() throws IOException {
      CookieHandler cookieHandler = CookieHandler.getDefault();
      if (cookieHandler != null) {
        try {
          URI uri = getURL().toURI();
          cookieHandler.put(uri, getHeaderFieldsDoNotForceResponse());
        } catch (URISyntaxException e) {
          throw new IOException(e);
        }
      }
    }
docs: Store any returned cookies.