Open MoslemCherif opened 5 years ago
That's the point of a Captcha code. You don't want to show the same string if the validation fails, otherwise your captcha can be cracked easily using a brute force approach.
If you're submitting the form using a normal POST request you should see a new code after each validation failure. Otherwise, if you are using AJAX requests you have to make sure that the captcha image is refreshed after the failed validation.
Something like this should work for you
<img id="captcha" src="{{ Captcha::src() }}" alt="captcha">
And the jQuery code that handles the refresh
var source = $("#captcha").attr('src');
$("#captcha").attr('src', source + '?timestamp=' + new Date().getTime());
I could display the captcha, everything is fine, until I submit, there comes the validation error "Wrong Captcha". After debugging, I saw that in the class
Mews\Captcha\Captcha
, there is a session value clearing$this->session->remove('captcha');
which leads to this problem. As a suggestion, the session key should be removed after successful result I am using Laravel 5.1 and PHP version 5.6