Google reCaptcha 说:invalid-request-cookie [英] Google reCaptcha says:invalid-request-cookie
问题描述
这是我第一次在我的网站上使用 recaptcha.
我正在使用 PHP API 来验证 recaptcha,它一直说 invalid-request-cookie
我在不同的论坛上发现 www.example.com 与 example.com 不同,所以我在没有 www
的情况下再次注册了我的网站,但仍然无法正常工作..
当我验证 recaptcha_response_field
和 recaptcha_challenge_field
时,值是正确的.
这是验证码检查器:
require_once(recaptchalib.php');$publickey = "不显示";//为了安全$privatekey = "不显示";//为了安全$错误=空;如果($_POST){$arr = array('a' => $_POST['task'], 'b' => $_POST['recaptcha_challenge_field'], 'c' => $_POST['recaptcha_response_field']);如果(修剪($arr['a'])=='验证码'){$resp = null;$错误=空;$captcha_result = '成功';$resp = recaptcha_check_answer( $privatekey, $_SERVER["REMOTE_ADDR"], $arr['b'], $arr['c'] );如果($resp->错误){$captcha_result = '失败';}回声 $captcha_result;}}
这是 HTML 代码:
<script type="text/javascript">var RecaptchaOptions = {标签索引:1,主题:'自定义',custom_theme_widget: 'recaptcha_widget'};<div id="recaptcha_widget" style="display:none"><div id="recaptcha_image" style="width: 200px; height: 57px; "></div><?php echo recaptcha_get_html($publickey, $error);?><div class="recaptcha_only_if_incorrect_sol" style="color:red">不正确.再试一次.<span class="recaptcha_only_if_audio">输入您听到的内容</span><input type="text" id="recaptcha_response_field" name="recaptcha_response_field"><div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Kumuha ng larawang CAPTCHA</a></div><script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0"></script><noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0" height="300" width="500" frameborder="0"></iframe><br><textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea><input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></div><script type="text/javascript">window.onload = 函数(){Recaptcha.focus_response_field();}<p id="captcha-error" style="color:red; font-weight:bold;"></p>
<div><a id="captcha-refresh" href="javascript:Recaptcha.reload()"></a></div><div class="recaptcha_only_if_image"><a id="captcha-audio" href="javascript:Recaptcha.switch_type('audio')"></a></div><div><a id="captcha-help" href="javascript:Recaptcha.showhelp()"></a></div><div id="circle-submit"></div>
有人能帮我解决这个问题吗?
谢谢,贾斯汀
As reCAPTCHA 支持说:
不,这不会导致无效域.这意味着您没有正确地向服务器提交 recaptcha_challenge_field.
因此,请确保使用 recapcha 正确呈现表单.查看此链接.
this is my first time in using recaptcha on my website.
I'm using PHP API to validate the recaptcha, it keeps saying invalid-request-cookie
I found out on different forum that www.example.com is different with example.com, so I register my site again without www
, but still it is not working..
When I verify the recaptcha_response_field
and recaptcha_challenge_field
the values are correct.
here is the captcha checker:
require_once(recaptchalib.php');
$publickey = "not displayed"; //for security
$privatekey = "not displayed"; //for security
$error = null;
if( $_POST ) {
$arr = array('a' => $_POST['task'], 'b' => $_POST['recaptcha_challenge_field'], 'c' => $_POST['recaptcha_response_field']);
if( trim($arr['a']) == 'captcha' ) {
$resp = null;
$error = null;
$captcha_result = 'success';
$resp = recaptcha_check_answer( $privatekey, $_SERVER["REMOTE_ADDR"], $arr['b'], $arr['c'] );
if( $resp->error ){
$captcha_result = 'fail';
}
echo $captcha_result;
}
}
here is the HTML code:
<div id="captcha-div">
<script type="text/javascript">
var RecaptchaOptions = {
tabindex: 1,
theme: 'custom',
custom_theme_widget: 'recaptcha_widget'
};
</script>
<div id="recaptcha_widget" style="display:none"><div id="recaptcha_image" style="width: 200px; height: 57px; "></div>
<?php echo recaptcha_get_html($publickey, $error); ?>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect. Try Again.</div>
<span class="recaptcha_only_if_audio">Type what you hear</span>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field">
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Kumuha ng larawang CAPTCHA</a></div>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0"></script>
<noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=6Le_X88SAAAAAAH3NEbkIr3w75SEQnQYwl96Y7f0" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></div>
<script type="text/javascript">
window.onload = function() {
Recaptcha.focus_response_field();
}
</script>
<p id="captcha-error" style="color:red; font-weight:bold;"></p>
</div>
<div><a id="captcha-refresh" href="javascript:Recaptcha.reload()"></a></div>
<div class="recaptcha_only_if_image"><a id="captcha-audio" href="javascript:Recaptcha.switch_type('audio')"></a></div>
<div><a id="captcha-help" href="javascript:Recaptcha.showhelp()"></a></div>
<div id="circle-submit"></div>
can anyone help me out with this issue?
Thanks, Justin
No, this will not result in the invalid domain. What this means is that you are not submitting the recaptcha_challenge_field to the server correctly.
So make sure you rendering the form with recapcha corectly. Check out this link.
这篇关于Google reCaptcha 说:invalid-request-cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!