CodeIgniter Forums
[ask] Flashdata problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [ask] Flashdata problem (/showthread.php?tid=17723)



[ask] Flashdata problem - El Forum - 04-13-2009

[eluser]hudar[/eluser]
Hi,

I found something weird in CI flashdata session. I call a model function from controller, then on model function I set flashdata using :

Code:
$this->session->set_flashdata('msg', 'blablabal');

then when the model function return to controller, and then I just want to read the flashdata on controller with :

Code:
$data = $this->session->flashdata('msg');

But It is weird that $data is still empty. But when I refresh the page, so that controller get called again, the $data show the right result which is 'blabala'.

When logout, and try again, get empty again, then get right result again on second call.

Do anybody know, why is that?


[ask] Flashdata problem - El Forum - 04-13-2009

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

That's not weird, that's normal. Flashdata is only meant to be available to the following request. That's the point of flashdata - to allow you to pass data from one request over to another, and then dispose of it when you're done. I think you are confusing flashdata with userdata.


[ask] Flashdata problem - El Forum - 04-13-2009

[eluser]hudar[/eluser]
Thanks for the greeting.

Yes, I think I understand your points.

Flashdata require nex request to read, isn't it?

So, in my app, I just read flashdata in controller when model call returned, so It still in the same request. Do you think this is the problem?

Anyway, thanks.


[ask] Flashdata problem - El Forum - 04-13-2009

[eluser]Thorpe Obazee[/eluser]
As for my experience, I've tried setting it and you can use it on the very same View.


[ask] Flashdata problem - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
[quote author="hudar" date="1239696966"]So, in my app, I just read flashdata in controller when model call returned, so It still in the same request. Do you think this is the problem?[/quote]

Sorry, I don't understand the question.


[ask] Flashdata problem - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
[quote author="bargainph" date="1239697508"]As for my experience, I've tried setting it and you can use it on the very same View.[/quote]

Try it again. I know that in 1.7.1 you can't do that. Smile