• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session Flashdata will not display until 2nd page load


I have users running through a Beta signup sequence. Once the email has been successfully submitted a quick bit of flash data is added and a new view (pending) is loaded (see code below):

if ( !$send )
  $this->session->set_flashdata('message','Doh!  The email did not send.');
  $this->session->set_flashdata('message','Success!  Your validation email has been sent.');

The display:
<h2>Almost done!</h2>
<p>&lt;?php echo $this->session->flashdata('message'); ?&gt;</p>
<h4>Please check your inbox for further instructions.</h4>

The problem is when the system takes you to either of these pages the flashdata does not display UNTIL you refresh the page or go back to the main page. It looks like the template library is not refreshing (or triggering) a refresh for the message to appear (best guess). Any thoughts how to solve?


You need to do this a different way, the flash data is working as intended ie setting as the page processes. That means it can't be read until you go to another page or refresh the one you're on. It's a bit like trying to set a cookie and retrieve it on the same page.

Send your view a variable and check for that instead.


You can take a look at our message library to get what you want.

nice thanks

This is usally cause by page caching!


Personally I do a redirect() instead of a view() that way it loads straight away. What's build() though?

Then redirect like this!
redirect('where_to', 'refresh');


[eluser]William Rufino[/eluser]
yeah, a flashdata will only display on a new page, so you have to redirect!

if you want to display it on the same "request" you are, why don't just use a normal attribute on the class?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.