CodeIgniter Forums
question for flashdata - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: question for flashdata (/showthread.php?tid=21540)



question for flashdata - El Forum - 08-12-2009

[eluser]Shiro[/eluser]
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
http://www.wrox.com/WileyCDA/WroxTitle/Professional-CodeIgniter.productCd-0470282452,descCd-DOWNLOAD.html

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.


question for flashdata - El Forum - 08-13-2009

[eluser]Shiro[/eluser]
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
redirect('welcome/admin','refresh');

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.