How to force recaptcha to expire your session?

Asked

Viewed 323 times

2

I am trying to make modifications with the recaptcha expiration message, but I can’t see it (occasionally if I leave a tab open, it appears), there is some way to force the recaptcha expiration callback?

In the case below the Alert does not run because I do not know what time to activate it.

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

 var expCallback = function() {
      alert('ok');
   };

1 answer

0

There is no way to force the recaptcha to expire session, just render it 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>

Place 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" async defer></script>

Source: https://stackoverflow.com/questions/28738949/fire-event-when-recaptcha-session-expires

Browser other questions tagged

You are not signed in. Login or sign up in order to post.