Welcome Guest, Not a member yet? Register   Sign In
flashdata suddenly not clearing on a page refresh
#1

[eluser]mdcode[/eluser]
This has me stumped. What was working on a site a month ago (and is still working on a near identical coded site, and in fact flashdata code is the same), is now not... When a project is edited successfully, I am using flashdata to display a successful message. This works as it should -- flashdata gets cleared on the next page load and the message no longer displays. However, if the project edit fails, while the failed message is displayed correctly, flashdata does not clear itself on the next page refresh. It also stops me from logging out of the system (destroying the session), and while the logout function redirects me to the correct page, session data is not cleared and the flashdata message is still there.

Even when doing a further successful edit, flashdata doesn't refresh itself to display the edit successful message, and doing another unsuccessful edit, shows the "cached" failed message. I have searched and searched the forums and Google, double checked the User Manual and correlated with the other site which works, and I'm getting nowhere. Just for the record I have found one thread here that details this error which was solved by turning off caching -- I am NOT using caching on this site.

CONTROLLER:
Code:
function edit()
{
// code for displaying the form fields and their variable options... nothing to do with flashdata - seriously

/* check if the form has been submitted */
        if($this->input->post('submit_form'))
        {
            if (is_numeric($this->uri->segment(3)))
            {
                $id = $this->uri->segment(3);
            }
            else
            {
                $id = FALSE;
            }
            $update = $this->projects_model->update($id);
            
            if ($update > 0)
            {
            $this->session->set_flashdata('flashmsg', '<div class="flash_green">The project has been edited successfully.</div>');
            redirect('/projects', 'refresh');
            }
            else
            {
            $this->session->set_flashdata('flashmsg', '<div class="flash_red">Project edit has failed.  Please try again.<br /><br />'.$this->db->last_query().'</div>');
            redirect('/projects', 'refresh');
            }
        }
        
        $data['project'] = $this->projects_model->get_all_project_details($id);
        
        $this->template->write_view('content', 'default/admin/projects_edit', $data);
        $this->template->render();
    }

VIEW:
Code:
&lt;!-- MAIN CONTENT DISPLAY --&gt;
        <div id="container">
        <div class="content">
            &lt;?php echo $this->session->flashdata('flashmsg'); ?&gt;
            &lt;?php echo $content ?&gt;
        </div>
        </div>

I'd really appreciate any pointers. Thanks in advance.
#2

[eluser]mdcode[/eluser]
I apologise for bumping this, but since I have had zero replies, I thought I needed to get it back up into better view. While not urgent, it is very important I get "some" feedback on why this might be happening.

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB