Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 9933)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 9935)
@@ -7,7 +7,10 @@
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.net.CookieHandler;
 import java.net.HttpURLConnection;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -199,6 +202,9 @@
     }
 
-    protected SessionId extractOsmSession() {
-        List<String> setCookies = connection.getResponse().getHeaderFields().get("Set-Cookie");
+    protected SessionId extractOsmSession() throws IOException, URISyntaxException {
+        // response headers might not contain the cookie, see #12584
+        final List<String> setCookies = CookieHandler.getDefault()
+                .get(connection.getURL().toURI(), Collections.<String, List<String>>emptyMap())
+                .get("Cookie");
         if (setCookies == null) {
             Main.warn("No 'Set-Cookie' in response header!");
@@ -267,5 +273,5 @@
                         tr("OSM website did not return a session cookie in response to ''{0}'',", url.toString()));
             return sessionId;
-        } catch (IOException e) {
+        } catch (IOException | URISyntaxException e) {
             throw new OsmOAuthAuthorizationException(e);
         } finally {
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9933)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9935)
@@ -9,4 +9,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.CookieHandler;
+import java.net.CookieManager;
 import java.net.HttpRetryException;
 import java.net.HttpURLConnection;
@@ -51,4 +53,8 @@
     private transient HttpURLConnection connection; // to allow disconnecting before `response` is set
     private transient Response response;
+
+    static {
+        CookieHandler.setDefault(new CookieManager());
+    }
 
     private HttpClient(URL url, String requestMethod) {
