Welcome Guest, Not a member yet? Register   Sign In
Flashdata delayed
#1

[eluser]fry.fr[/eluser]
Hello!

I'm using Codeigniter for a while now and got into a problem I just can't find a solution for.

The application I'm working on uses Flashdata to display error messages to the user.
Here is the code example:
Code:
$info_message['type'] = 'error';
$info_message['message']= 'Es ist ein Fehler aufgetreten, bitte versuche es noch einmal.';
$this->session->set_flashdata($info_message);
redirect('groups');

On the "groups" page the error message should be displayed, but it's not there. If a browser refresh is performed, the message appears.
This error occurs often, but not always, sometimes the message appears as expected without the manual browser refresh. It seems to have a connection to the page loading speed, if the page loads instantly the error message is not there, if the page loads last a few milliseconds the flashdata message is there on the first request.

As you can see I'm using the redirect, so there should be a new request.
Using redirect('groups', 'refresh') does not change this behaviour.

Thanks for your help.
#2

[eluser]InsiteFX[/eluser]
Try this:
Code:
redirect('groups', 'refresh');
#3

[eluser]PhilTem[/eluser]
Maybe it's a browser cache issue? Have you tried setting the page's header to tell the browser to not cache the content?
#4

[eluser]fry.fr[/eluser]
[quote author="InsiteFX" date="1332609487"]Try this:
Code:
redirect('groups', 'refresh');
[/quote]

Already tried this, didn't change anything.
#5

[eluser]fry.fr[/eluser]
[quote author="PhilTem" date="1332610129"]Maybe it's a browser cache issue? Have you tried setting the page's header to tell the browser to not cache the content?[/quote]

Is there a way to do it wiht codeigniter? or via htaccess?
#6

[eluser]InsiteFX[/eluser]
Try keep_flashdata

Code:
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
#7

[eluser]fry.fr[/eluser]
[quote author="InsiteFX" date="1332611257"]Try keep_flashdata

Code:
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
[/quote]

Thanks for the header code.

keep_flashdata can't help me in this case because the actual flashdata is not lost. It's send with the next request, but sometimes a litte too late.
#8

[eluser]fry.fr[/eluser]
I also didn't experiance this error with wired dsl connections, just with the wireless 3g connection I use when traveling... maybe it's a really a problem with the cache or something.




Theme © iAndrew 2016 - Forum software by © MyBB