Welcome Guest, Not a member yet? Register   Sign In
flashdata not set?
#1

[eluser]garrettheel[/eluser]
I'm using flashdata to display errors when a user does something wrong on the site. Here's an example of it being used (page is a custom library):

Code:
if($id == NULL)
    {
        $this->session->set_flashdata('error', 'A post ID was not specified.');
        $this->page->load('error');
    }

The error page simply echoes $this->session-flashdata('error');

The problem is, the first time the user triggers this, the error is not displayed. However, if the page is reloaded then the error is displayed. Why is this?
#2

[eluser]KPowell[/eluser]
flashdata is set for the next page load. So, if you were doing a redirect instead of just calling another method, you'd be good to go. In this case, you could just set a class variable to that and have that display if you don't want to do a redirect.




Theme © iAndrew 2016 - Forum software by © MyBB