Welcome Guest, Not a member yet? Register   Sign In
[ask] Flashdata problem
#1

[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?
#2

[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.
#3

[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.
#4

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

[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.
#6

[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




Theme © iAndrew 2016 - Forum software by © MyBB