afelipe270891 / recaptcha

Automatically exported from code.google.com/p/recaptcha
0 stars 0 forks source link

invalid-request-cookie using reCAPTCHA with AJAX #207

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I have the very famous problem "invalid-request-cookie". I searched a lot 
of solutions on Google but I can't solve my problem and I don't know why...

I checked if the code send the data via POST, if the <form> has method="post", 
if the private and public key are right, if the domain license is right etc. 
but I really can't solve my problem... Could you help me?

Here my code:

JAVASCRIPT:

var nome = $("#nome").val();
    var password = $("#password").val();
    var email = $("#email").val();
    var sesso = $("#sesso").val();
    var recaptcha_challenge_field = $("#recaptcha_challenge_field").val();
    var recaptcha_response_field = $("#recaptcha_response_field").val();

  //chiamata ajax
    $.ajax({

     //imposto il tipo di invio dati (GET O POST)
      type: "POST",

      //Dove devo inviare i dati recuperati dal form?
      url: "register-new.php",

      //Quali dati devo inviare?
     data : { nome : 'nome', password : 'password', email : 'email', sesso : 'sesso', recaptcha_challenge_field : 'recaptcha_challenge_field', recaptcha_response_field : 'recaptcha_response_field' },

      //Inizio visualizzazione errori
      success: function(msg)
      {
        $("#risultato").html(msg); 
        $(".tornaindietro").click(function() {
                 $("#registrazione").animate({
                     "left": "0px",
                     "opacity": "1"
                 }, 300, "easeOutExpo");
                 $("#risultato").animate({
                     "left": "600px",
                     "opacity": "0"
                 }, 300, "easeOutExpo");
             });
      }

      ,
      error: function()
      {
        alert("Chiamata fallita, si prega di riprovare..."); //sempre meglio impostare una callback in caso di fallimento
      }
    });
  });

//====================================//

HTML:

<form method="post" id="registrazione" name="registrazione">
         <div class="lol">
         <ul class="options">
          <li>Nome</li>
          <li><div id="nome-ic"><input type="text" id="nome"></div></li>
          <li>Password</li>
          <li><div id="password-ic"><input type="password" id="password"></div></li>
          <li>Email</li>
          <li><div id="email-ic"><input type="email" id="email"></div></li>
          <li>Sesso</li>
          <li><select id="sesso">
           <option value="M">Maschio</option>
           <option value="F">Femmina</option>
          </select></li>
         </ul>
         </div>
         <div style="width: 318px; height: 129px; position: absolute; top: 50%; margin-top: -64px; right: 20px;">
         <?php
          require_once('recaptchalib.php');
  $publickey = "6Ldwkv0SAAAAANaG6xORJ0guDkZcgpx55FrH8YiV"; 
  echo recaptcha_get_html($publickey);
          ?>
          </div>
         <input type="button" id="registrati-bottone" value="Registrati" />
         </form>

Original issue reported on code.google.com by davideno...@gmail.com on 12 Nov 2014 at 1:07

GoogleCodeExporter commented 8 years ago
Is it possible that the issue depends by my name servers? Because I have 
CloudFlare Pro protection and the DNS structure is like this:

http://www.arilhotel.com/ >> has CloudFlare name servers
CloudFlare name servers >> has the Virtual Private Server IP

Original comment by davideno...@gmail.com on 12 Nov 2014 at 1:11

GoogleCodeExporter commented 8 years ago
No, I've tried with another domain and the issue persists

Original comment by davideno...@gmail.com on 12 Nov 2014 at 1:17

GoogleCodeExporter commented 8 years ago
I solved... The javascript didn't send the data because I used the '' in:

data : { nome : 'nome', password : 'password', email : 'email', sesso : 
'sesso', recaptcha_challenge_field : 'recaptcha_challenge_field', 
recaptcha_response_field : 'recaptcha_response_field' }

Original comment by davideno...@gmail.com on 12 Nov 2014 at 2:39