Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32204)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32205)
@@ -105,9 +105,9 @@
      */
     private void getCookie() throws IOException {
-        boolean cookied = false;
+        boolean sucess = false;
         int retries = cRetriesGetCookie;
         try {
             searchFormURL = new URL(baseURL + "/scpc/accueil.do");
-            while (cookied == false && retries > 0) {
+            while (sucess == false && retries > 0) {
                 urlConn = (HttpURLConnection)searchFormURL.openConnection();
                 urlConn.setRequestProperty("Connection", "close");
@@ -118,13 +118,22 @@
                     BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
                     while(in.readLine() != null) {}  // read the buffer otherwise we sent POST too early
-                    String headerName=null;
+                    sucess = true;
+                    String headerName;
                     for (int i=1; (headerName = urlConn.getHeaderFieldKey(i))!=null; i++) {
-                        if (headerName.equals("Set-Cookie")) {
+                        if (Main.isDebugEnabled()) {
+                            Main.debug(headerName + ": " + urlConn.getHeaderField(i));
+                        }
+                        if ("Set-Cookie".equals(headerName)) {
                             cookie = urlConn.getHeaderField(i);
-                            cookie = cookie.substring(0, cookie.indexOf(";"));
-                            cookieTimestamp = new Date().getTime();
-                            Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
-                            cookied = true;
-                        }
+                            if (cookie.isEmpty()) {
+                                Main.warn("received empty cookie");
+                                cookie = null;
+                            } else {
+                                cookie = cookie.substring(0, cookie.indexOf(';'));
+                                cookieTimestamp = new Date().getTime();
+                                Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
+                                break;
+                            }
+                        } 
                     }
                 } else {
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 32204)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 32205)
@@ -61,4 +61,5 @@
             Main.warn("removed a duplicated layer");
         } catch (WMSException e) {
+            Main.warn(e);
             errorMessage = e.getMessage();
             wmsLayer.grabber.getWmsInterface().resetCookie();
