Reputation: 143
So this is a really weird one.
I have recently discovered Code Ignitor's flash data, which is exactly what i need.
However, I am noticing that sometimes I experience issues with it. Splitting it right down to the barebones(function one does literally nothing more than this except using real data, and function two does nothing more before fetching flash data, which is why I am confident I can reduce them down to this).
controller_one :
function one()
{
$data['foo'] = 'bar';
$this->session->set_flashdata('extra_data', $data);
redirect('controller_two/two');
}
controller-two :
function two()
{
if($this->session->flashdata('extra_data'))
{
var_dump($this->session->flashdata('extra_data'));
}
}
The third file is just a static page with a static link to controller_one/one say index.
Now if i go index and click the link, it will correctly redirect and dump the data - as expected.
Now - and this is where it gets weird. If I go to the index - wait 10minutes + then click the link, it redirects but the flashdata is empty(NULL).
I really don't see how waiting on a static page to click a static can affect what is happening during the redirect between the two functions - causing loss of flash data, as that flashdata isn't even set until that link is clicked and the redirect happens immediately after that in both cases.
I have also tried to var_dump($this->session->flashdata('extra_data')); die;
just before the redirect, and in both cases the data is set and correct - no difference, so it must be being lost during the redirect itself - I just can't comprehend how a wait before that influences that, but it must be - somehow.
It's fairly easy for me to work around, using standard sessions or whatever, but as flash data does exactly what I want, it seems more appropriate to use this - it's just not working if the user lingers on the page before it's set.
So any theories as to why, or better yet solutions, would be greatly appreciated.
Upvotes: 0
Views: 213