Flash数据未在Codeigniter中清除

I am using Codeigniter 2.1.4 and I have facing some issues with flashdata. When I successfully submit record I can display the flashdata message. But if go to the other page from the page where flashdata message was displayed and then go back to previous page using browser back button it shows me flashdata message again.
How to clear flashdata message once it used? I think its not the flashdata issue its cache problem. I am confused why this is happening. If its cache issue then how to remove it?

Below is code I have used,

//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");

// In the view of controller
$data['message'] = $this->session->flashdata('message');

// In the view page
echo $message;

Flash disappears only after next refresh

$this->session->set_flashdata('message', "Record updated successfully.");

After setting the flashdata redirect to some function or to the same function.

your code in controller is right

//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");
redirect('controller_name/function_name','refresh');

now in view use like this

if($this->session->flashdata('message')){echo $this->session->flashdata('message');}

hope it will work

You must redirect the page somewhere after $this->session->set_flash('item','value');

Example:

if ($this->form_validation->run() == FALSE){
    $this->session->set_flashdata('error',validation_errors());
    redirect(base_url().'user/login');
}
else{
    $this->session->set_flashdata('success','Thank you');
    redirect(base_url().'user/login');
}

Usually developer make a mistake when they submit data to same page. They set flash data but forget to redirect.

If you refresh in the same controller function the flashdata won't be deleted.Also going back and forth in the browser does't affect the flashdata. to clear the flashdata redirect to another controller function and it will work.

if you want to clear set_flash in controller or another view file, then you can use this simple code.

$this->session->set_flashdata('error', 'User not found...'); //create set_flash

destroy set_flash

//echo "<pre>"; print_r($_SESSION); die; //for check 

if(isset($_SESSION['error'])){
    unset($_SESSION['error']);
}