Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reCAPTCHA: why can't I check the same result twice?

I mean if I check first clients input and it is OK the second check of the same input is always false... Why is that?

I really need ability to check it twice (one for client side validation and second for server side validation)

Thanks in advance!!!

EDIT

Clarifying:

If user's input is ok and recaptcha returns true (I do it through ajax to my server which sends request to recaptcha's server) the form is submitting and sends via POST also 2 variables: recaptcha_challenge_field value and recaptcha_response_field value (which was already checked) and than my server asks recaptcha's server to check again this two values to do server side validation.

Jquery code:

$("#form_id").find("button").click(function(){
    var c = $("#recaptcha_challenge_field").val(),
        r = $("#recaptcha_response_field").val();

    $.ajax({
        url: "/ajax/captcha?challenge=" + c + "&response=" + r,
        dataType: "json",
        success: function(data){
            if(data['is_valid']){
                $.ajax({
                    url: "/ajax/captcha?challenge=" + c + "&response=" + r,
                    dataType: "json",
                    success: function(data){
                        if(data['is_valid']){
                            alert('OK');
                        }else{
                            alert('FAILED');
                        }
                    }
                });
            }else{
                Recaptcha.reload();
            }
        }
    });
    return false;
});

So, as you can see there are two absolutely identical operations with different result (it alerts only FAILED).

like image 542
Vitalii Ponomar Avatar asked Feb 10 '12 12:02

Vitalii Ponomar


People also ask

Why is reCAPTCHA impossible?

One of the most common reasons why this error occurs is that of an outdated Chrome version. reCAPTCHA will actively look at the browser version before allowing you access. This is applicable to all browser versions, not just Chrome. In this case, the solution is to update Google Chrome to the latest version.

How long does it take for reCAPTCHA to reset?

If you change your domain, update reCAPTCHA settings It can take up to 30 minutes for domain updates to take effect.

How long do CAPTCHA tokens last?

Note: reCAPTCHA tokens expire after two minutes. If you're protecting an action with reCAPTCHA, make sure to call execute when the user takes the action rather than on page load. You can execute reCAPTCHA on as many actions as you want on the same page.


1 Answers

Because it is stored in a session that is cleared when the result is submitted. On page load, a new session variable for that CAPTCHA value is generated.

like image 151
Barry Chapman Avatar answered Sep 22 '22 17:09

Barry Chapman