I'm using kohana 3.0 with kolanos-kohana-captcha-2ba7a6开发者_C百科a module from earlier versions. Everything works fine, but I can't figure out one thing: how do I create new captcha image for current form? For example user can't read characters and clicks 'new image'. The ajax is sent, but the response is (almost always) the same image. In the controller, I tried the following:
echo new Captcha_Basic;
Captcha::instance()->__destruct();
echo Captcha::instance();
echo $captcha->generate_challenge();
and even some more, but it's almost(??) always the same image. I even tried to delay image loading on client-side, but nothing works. Any suggestions?
I had the same problem and I have solved it by simply editing system/libraries/drivers/Captcha.php
file. I have changed the image_render()
function so that a random string is passed as a GET parameter in the src
attribute's url.
I reckon that though ajax is not caching, the browser is caching the image's src
url. Every ajax call to generate a new image does indeed generate a new image. However, the src
attribute the CAPCHA library returns is always the same, causing the browser to simply show the same image it has cached. Including a randomly generated string as a GET parameter causes the browser to fetch the new image.
精彩评论