Welcome Guest, Not a member yet? Register   Sign In
Session not consistent
#1

[eluser]Unknown[/eluser]
Dear All,

I tried to store captcha word that i create in session using

Code:
$this->session->set_userdata(array(  
    'captcha_word' => $cap['word'],
    'captcha_time' => $cap['time']
  ));
And then, I'll retrieve using

Code:
$word = $this->session->userdata('captcha_word');
to be compared with user input for captcha.

for debugging purpose , after storing in session i print using
print_r($this->session->userdata);
and got value
Quote:Array ( [session_id] => 22665cec01f065cc6e40a0d890051ca8 [ip_address] => 127.0.0.1 [user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22 [last_activity] => 1364354023 [user_data] => [captcha_word] => OddwxM....

But the problem is, when I retrieve the session data later, I found out that the value of captcha_word is
Quote:Array ( [session_id] => 22665cec01f065cc6e40a0d890051ca8 [ip_address] => 127.0.0.1 [user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22 [last_activity] => 1364354023 [user_data] => [captcha_word] => HnnOk ....

the session_id match, but the captcha_word is not the same with the value that i store previously.
Between store and retrieve, there is no process that affect the value of captcha_word in session.

I wonder what cause the problem and help will be appreciated.

regards,
ganda
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

You must be resetting the word on each request. You should do a check to make sure you're only setting it if it's not already set. However, if the form is submitted, and the CAPTCHA doesn't match, then you should set it to a new one, to prevent replays. Please post your controller code.




Theme © iAndrew 2016 - Forum software by © MyBB