I am developing the captcha image verification with textimage module.
Here the text image code is storing in the session variable $_SESSION['captcha'] in the function _textimage_captcha_code(). But after submitting the form in the validation function textimage_captchavalidate(&$captcha_word, &$correct) the session variable is always returning the blank value.

The below function has the session variable for storing text image code

function _textimage_captcha_code() {
$consts='bcdgjxvmnprst';
$vowels='aeiou';

for ($x=0; $x < 6; $x++) {
mt_srand ((double) microtime() * 1000000);
$const[$x] = drupal_substr($consts,mt_rand(0,drupal_strlen($consts)-1),1);
$vow[$x] = drupal_substr($vowels,mt_rand(0,drupal_strlen($vowels)-1),1);
}

$string = $const[0] . $vow[0] .$const[2] . $const[1] . $vow[1] . $const[3] . $vow[3] . $const[4];
$string = drupal_substr($string,0,rand(4,6));

//everytime we create a new code, we write it to session
$_SESSION['captcha'] = drupal_strtolower($string);

if(variable_get('textimage_captcha_use_only_upper',0)) {
$string = drupal_strtoupper($string);
}

return $string;
}

The below function is validating the captcha image. But here the session variable is returning blank value.

function textimage_captchavalidate(&$captcha_word, &$correct) {

$captcha_word = drupal_strtolower($captcha_word);
if (($_SESSION['captcha'] != '') && $captcha_word == $_SESSION['captcha']) {
$correct = true;
}
else {
$correct = false;
form_set_error('captcha_response', t('The image verification code you entered is incorrect.'));
}

}

Because of this problem I am always getting error message. What is the problem in these functions?