Problema login arduino ethernet

Con questo codice faccio l'autenticazione e accendo il led, ma come già successo in precedenza dopo il clic per accendere il led
(comunque il led si accende) torno alla pagina di login, se clicco sul login questa volta non mi chiede le credenziali di accesso
ma vado direttamente alla pagina per spegnere il led e così all'infinito.

#define WEBDUINO_AUTH_REALM "Prova Autenticazione"

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"


static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };


static uint8_t ip[] = { 192, 168, 1, 220 };

#define PREFIX ""
WebServer webserver(PREFIX, 80);

boolean Rele1 = false;

void defaultCmd(WebServer &server, WebServer::ConnectionType type,char *url_param, bool param_complete)
                     
{
  server.httpSuccess();
  if (type != WebServer::HEAD)
  {
  
    {
    String s = "";
 
     if (param_complete == true)
    {
      s = url_param;
 
      if ( s == "R1=ON")
      {
        Rele1 = true;
        digitalWrite(3, HIGH);
      }
      else if ( s == "R1=OFF")
      {
        Rele1 = false;
        digitalWrite(3, LOW);
      }
   }       
 
P(helloMsg) = "<h1>Prova Autenticazione</h1><a href=\"private.html\">Accesso</a>";

    server.printP(helloMsg);
     server.print("<h2>User = 1234   Password = 1234</h2>");  
  }
}
}


void privateCmd(WebServer &server, WebServer::ConnectionType type,
         char *url_param, bool param_complete)
           
           
           
{ 
 if (server.checkCredentials("MTIzNDoxMjM0"))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Acesso eseguito</h1>";
      server.print("<table border=\"1\">");
    server.print("<tr><td>Stato Rele</td><td>Comandi</td></tr>");
     if(Rele1 == true)
      server.print("<tr><td style=\"color: red;\">RELE 1 ON</td><td>");
    else
      server.print("<tr><td style=\"color: black;\">RELE 1 OFF</td><td>");
 
    if(Rele1 == false)
    server.print("<input type= button value='clicca qui'onclick=\"location.href='index.html?R1=ON'\">");
    else
   
   server.print("<input type= button value='clicca qui'onclick=\"location.href='index.html?R1=OFF'\">");
 
    server.print("</td></tr>");
      server.printP(helloMsg);
        
    }
  }
  
       else
 
  {
    /* send a 401 error back causing the web browser to prompt the user for credentials */
    server.httpUnauthorized();
  }
  

}


void setup()
{
  Ethernet.begin(mac, ip);
  webserver.setDefaultCommand(&defaultCmd);
  webserver.addCommand("index.html", &defaultCmd);
  webserver.addCommand("private.html", &privateCmd);
  webserver.begin();
  
  delay(100);
  
   //definisci i pin 2 3 4 in uscita
  pinMode(3, OUTPUT);
 
 
  //inizializza i le uscite
  digitalWrite(3, LOW);
 
}

void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

Ho trovato questa guida molto interessante -->Webduino recuperare parametri da un URL
e anche questo --> Webduino aggiungere pagine web al webserver Arduino

A dire il vero proprio da li ho preso spunto, ma il problema è che non riesco a gestire il login.
Dopo il login se accendo / spengo il led mi torna sempre nella pagina di login...

Non conosco così bene il Webduino da capirne con sicurezza il comportamento.

Il problema credo sia questo, cosa che tu hai individuato qualche post più su:

Si, lo so che non funziona.... ho tirato fuori il mio Arduino R3 + Ethernet shield e sto provando "con mano" il codice.
Il problema come ti ho detto nel messaggio precedente è che ogni volta che invii un comando all'Arduino lui fa il check della login.
Bisognerebbe aggiungere una variabile firstlogin in modo da discriminare se il login è stato già fatto.

Prima di tutto Buon anno a tutti

Io ho pastrocchiato questo, l'ho testato e devo dire che funziona, però gradirei che gli diate un'occhiata:

#define WEBDUINO_AUTH_REALM "Prova Autenticazione"

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"


static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };


static uint8_t ip[] = { 192, 168, 1, 220 };

#define PREFIX ""
WebServer webserver(PREFIX, 80);

boolean Rele1 = false;
boolean Rele2 = false;
boolean Rele3 = false;

void defaultCmd(WebServer &server, WebServer::ConnectionType type,char *url_param, bool param_complete)
                     
{
  server.httpSuccess();
  if (type != WebServer::HEAD)
 {
    String s = "";
 
     if (param_complete == true)
    {
      s = url_param;
 
      if ( s == "R1=ON")
      {
        Rele1 = true;
        digitalWrite(3, HIGH);
      }
      else if ( s == "R1=OFF")
      {
        Rele1 = false;
        digitalWrite(3, LOW);
      }
 
      if ( s == "R2=ON")
      {
        Rele2 = true;
        digitalWrite(5, HIGH);
      }
      else if ( s == "R2=OFF")
      {
        Rele2 = false;
        digitalWrite(5, LOW);
      }
 
      if ( s == "R3=ON")
      {
        Rele3 = true;
        digitalWrite(6, HIGH);
      }
      else if ( s == "R3=OFF")
      {
        Rele3 = false;
        digitalWrite(6, LOW);
      }
    }
 
P(helloMsg) = "<h1>Prova Autenticazione</h1><a href=\"private.html\">Accesso</a>";

    server.printP(helloMsg);
     server.print("<h2>User = 1234   Password = 1234</h2>");  
  }
}



void privateCmd(WebServer &server, WebServer::ConnectionType type,
         char *url_param, bool param_complete)
         
         
 {
    String s = "";
 
     if (param_complete == true)
    {
      s = url_param;
 
      if ( s == "R1=ON")
      {
        Rele1 = true;
        digitalWrite(3, HIGH);
      }
      else if ( s == "R1=OFF")
      {
        Rele1 = false;
        digitalWrite(3, LOW);
      }
 
      if ( s == "R2=ON")
      {
        Rele2 = true;
        digitalWrite(5, HIGH);
      }
      else if ( s == "R2=OFF")
      {
        Rele2 = false;
        digitalWrite(5, LOW);
      }
 
      if ( s == "R3=ON")
      {
        Rele3 = true;
        digitalWrite(6, HIGH);
      }
      else if ( s == "R3=OFF")
      {
        Rele3 = false;
        digitalWrite(6, LOW);
      }
    }        
                   
{ 
 if (server.checkCredentials("MTIzNDoxMjM0"))
  {
    server.httpSuccess();
    if (type != WebServer::HEAD)
    {
      P(helloMsg) = "<h1>Accesso eseguito</h1>";
      server.print("<table border=\"1\">");
    server.print("<tr><td>Stato Rele</td><td>Comandi</td><td>");
 
    if(Rele1 == true)
      server.print("<tr><td style=\"color: red;\">RELE 1 ON</td><td>");
    else
      server.print("<tr><td style=\"color: black;\">RELE 1 OFF</td><td>");
 
    if(Rele1 == false)
 
    server.print("<input type= button value='Accendi'onclick=\"location.href='private.html?R1=ON'\">");
    else
  
   server.print("<input type= button value='Spegni'onclick=\"location.href='private.html?R1=OFF'\">");
 
    server.print("</td></tr>");
 
    if(Rele2 == true)
      server.print("<tr><td style=\"color: red;\">RELE 2 ON</td><td>");
    else
      server.print("<tr><td style=\"color: black;\">RELE 2 OFF</td><td>");
 
    if(Rele2 == false)
   
      server.print("<input type= button value='clicca qui'onclick=\"location.href='private.html?R2=ON'\">");
    else
    server.print("<input type= button value='clicca qui'onclick=\"location.href='private.html?R2=OFF'\">");
 
    server.print("</td></tr>");
 
    if(Rele3 == true)
   
      server.print("<tr><td style=\"color: red;\">RELE 3 ON</td><td>");
    else
      server.print("<tr><td style=\"color: black;\">RELE 3 OFF</td><td>");
 
    if(Rele3 == false)
 
    server.print("<input type= button value='clicca qui'onclick=\"location.href='private.html?R3=ON'\">");
    else
  
    server.print("<input type= button value='clicca qui'onclick=\"location.href='private.html?R3=OFF'\">");
 
    server.print("</td></tr>");
 
  
      server.printP(helloMsg);
        
    }
  }
  
       else
 
  {
    /* send a 401 error back causing the web browser to prompt the user for credentials */
    server.httpUnauthorized();
  }
  

}
}

void setup()
{
  Ethernet.begin(mac, ip);
  webserver.setDefaultCommand(&defaultCmd);
  webserver.addCommand("index.html", &defaultCmd);
  webserver.addCommand("private.html", &privateCmd);
  webserver.begin();
  
  delay(100);
  
   //definisci i pin 2 3 4 in uscita
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
 
 
  //inizializza i le uscite
  digitalWrite(3, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
 
}



void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

Era un po' che non mettevo mani sulla lib Ethernet.

Allora ricordavo bene la risposta che ti serve è sul char(c). Ho preso un esempio dell'ide e ti ho inserito l'autenticazione base64

Ora sto provando a passare il controllo dei led nel tuo codice, ma senza successo