• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flashdata always seems one page behind

Hi there,

just started trying to use the flash. It seems that it is always 1 request behind. Consider the following code
$this->session->set_flashdata( 'flash', 'You have already provided us with your details' );
$this->load->view( 'competition_form' );

The flash message doesn't show the first time the view is loaded, only if refreshed. How can one get it to show in the view file?

I am actually trying to use it along with form validation and my full code looks like this:

if( $this->validation->run() == FALSE )
            $this->session->set_flashdata( 'flash', 'Please fill in the form correctly…' );    
            if( !$this->session->userdata( 'competition' ) )
                $this->load->model( 'entry' );
                $this->session->set_userdata( 'competition', TRUE );
                $this->session->set_flashdata( 'flash', 'Thank you. Your details have been saved and a confirmation email sent.' );
                $this->session->set_flashdata( 'flash', 'You have already provided us with your details. Multiple submissions are not allowed.' );
        $this->load->view( 'competition_form' );

[eluser]Pascal Kriete[/eluser]
The definition of flashdata is that it shows on the next page load. No the next view load. If you need text in a view just pass it as part of the data array.

thanks for the reply. So in what circumstance might you want to use flash data? Just so I can get some idea of when it might be useful for me. Thanks a lot.

[eluser]Derek Allard[/eluser]
The manual gives a few examples of circumstances gabe, take a look. I also gave a few examples on my blog when I originally wrote these. http://www.derekallard.com/blog/post/enh...n-library/

Thanks, Derek

You have a well-nice blog!


I use flash say when an event happens, such as creating an account, logging in, posting..etc Smile Nice feedback for the user.

aha and then after setting the flash redirect to another page?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

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