[eluser]Ebot Ndip-Agbor[/eluser]
Having a really strange problem, with validating captcha in one of my controllers. In this controller I do normal validation routine(produce captcha with CI captcha plugin, stored it in the session, use a callback method to validated when form data is posted ).
For the first controller method where I use captcha , validation works fine. But in a second method of same controller, the captcha validation is always false.
I just found out that in the second controller method, a different security code is stored in the session each time.
Let me explain with some code
Code:
//used by both methods to produce captcha
function generateCaptcha()
{
//load the captcha plugin
$this->load->plugin('captcha');
//generate captcha
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url().'captcha/',
'font_path' => base_url().'system/fonts/texb.ttf',
'img_width' => '115',
'img_height' => 50,
'expiration' => 7200
);
$cap = create_captcha($vals);
//save the captcha word in db_session
$sesdata['captchacode']=$cap['word'];// A different word is always stored in session, so callback keeps on failing (problem only with second controller method)
$this->db_session->set_userdata($sesdata);
return $cap;
}
But as I said the captcha works perfectly for the first controller method. I would appreciate some help.