Welcome Guest, Not a member yet? Register   Sign In
Session Flashdata will not display until 2nd page load
#1

[eluser]RJ[/eluser]
Hello,

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):

Code:
if ( !$send )
{
  $this->session->set_flashdata('message','Doh!  The email did not send.');
  $this->template->build('signup');
}
else
{
  $this->session->set_flashdata('message','Success!  Your validation email has been sent.');
  $this->template->build('pending');
}

The display:
Code:
<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?

Thanks
#2

[eluser]louisl[/eluser]
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.
#3

[eluser]RJ[/eluser]
thanks
#4

[eluser]n0xie[/eluser]
You can take a look at our message library to get what you want.
#5

[eluser]RJ[/eluser]
nice thanks
#6

[eluser]InsiteFX[/eluser]
This is usally cause by page caching!

InsiteFX
#7

[eluser]Ninjabear[/eluser]
Personally I do a redirect() instead of a view() that way it loads straight away. What's build() though?
#8

[eluser]InsiteFX[/eluser]
Then redirect like this!
Code:
redirect('where_to', 'refresh');

InsiteFX
#9

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




Theme © iAndrew 2016 - Forum software by © MyBB