question for flashdata

Dear all,

I have a question for the flashdata,
I had learn from the book from Wrox, Professional CodeIgniter
This is the source code, I download from

I found that for the admin login, flashdata doesn't work correctly.

The first time I type wrong username and password, no error display, when I type it second time then the error will be display.

I do another testing on it. In a view page, I added
$this->session->set_flashdata('test', '<div class=\'message\'>test</div>');
echo $this->session->flashdata('test');

The first time view the page, the flashdata test didn't show out, only I refresh it then it come out, I deleted the cookie and run the code again still didn't displayed. It has to be run second time then the flashdata will display, I am a bit confuse about the flashdata usage.

I found out answer,
after use the flashdata
For example,
$this->session->set_flashdata('error', '<div class=\'message\'>Sorry, your username or password is incorrect!</div>');

It must be follow by refresh the page

if not the message would not display out, it need to run second time.

This is why, the set_flashdata('test','value') does work in the first place.

I think this is related with the machanism cookie, maybe the wiki of the flashdata need to state it out.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.