Welcome Guest, Not a member yet? Register   Sign In
$this->session->set_flashdata inserting the wrong data.
#1

[eluser]Unknown[/eluser]
Look at this code:

Code:
$this->session->set_flashdata('prev_page', $this->uri->uri_string());
echo $this->uri->uri_string();
echo $this->session->flashdata('prev_page');
I have it running at each controller call.
When visiting mywebsite/index.php/home/

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

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

The controller functions in question:

Code:
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');
}

}
The strange thing is, this is only an issue on the index, all other functions work fine.
Why could this be happening?
#2

[eluser]karael[/eluser]
Try without using index if it doesn't work. Just like this:

Code:
public function index()
{
  $this->index2_exemple();
}

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

    } else {

        redirect('disclaimer');
    }

}
#3

[eluser]jairoh_[/eluser]
from what i know and experienced, you can retrieve the right value of flashdata when you redirect to a url then call it.




Theme © iAndrew 2016 - Forum software by © MyBB