为什么Codeigniter set_flashdata()会插入错误的信息?

Look at this code:

$this->session->set_flashdata('prev_page', $this->uri->uri_string());
echo $this->uri->uri_string();
echo $this->session->flashdata('prev_page');

When visiting mywebsite/index.php/home/

echo $this->uri->uri_string(); prints home

echo $this->session->flashdata('prev_page'); prints home/picktype, a completely different function in the same controller!

The controller functions in question:

class Home extends MY_Controller {

function __construct()
{
    parent::__construct();
}

public function index()
{   
    if($this->input->cookie('disclaimer_seen_token'))
    {
        $this->load->view('home');

    } else {

        redirect('disclaimer'); 
    }

}

public function picktype()
{   
    $this->load->view('picktype');
}

}

Why could this be happening?

Your flashdata has not been updated until you 'redirect' back to another page.

So your $this->session->flashdata('prev_page') is your LAST page before the redirect.

The docs specifically state:

CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared