How to force the recaptcha to expire your session?

1

I'm trying to make modifications with the recaptcha's expiration message, but I can not see it (occasionally if I leave a tab open, it appears), is there any way to force recaptcha's expire callback?

In the case below the alert is not executed because I do not know how long it will be activated.

var onloadCallback = function() {
     grecaptcha.render('g-recaptcha', {
          'sitekey' : '6LcaNiwUAAAAAEdD5whzKq-9b1cXMlLexxBxcXhO',
          'expired-callback' : expCallback
        });
  };

 var expCallback = function() {
      alert('ok');
   };
    
asked by anonymous 25.08.2017 / 21:24

1 answer

0

There is no way to force the recaptcha to expire session, it only renders after it expires.

Use a callback parameter using grecaptcha.reset()

For example:

Put this in the header.

<script>
   var callback = function() {
      grecaptcha.render('id-of-render-element', {
         'sitekey': 'your-site-key',
         'expired-callback': expCallback
       });
   };
   var expCallback = function() {
      grecaptcha.reset();
   };
</script>

Put this after the element that will be used to render reCAPTCHA.

<div id="id-of-render-element"></div>
<script src="https://www.google.com/recaptcha/api.js?onload=callback&render=explicit"asyncdefer></script>

Source: link

    
25.08.2017 / 21:32