I have a session that I turn into a variable $userID
.
I now need to use the variable within a different controller. I have tried to start a new session after the session $this->session->sess_destroy();
.
Then on my second controller I have tried to get the session data but I am getting NULL.
First controller
public function index()
{
if ($this->input->post('tid')) {
$this->session->userdata('user_id');
$userID = $this->session->userdata('user_id');
$this->session->sess_destroy();
$this->session->set_userdata($userID);
$this->input->post('userid');
$data['tid'] = $this->input->post('tid');
$this->load->view('client/login', $data);
} else {
header("Location: " . base_url() . "index.php/select");
die();
}
}
Second controller
private function getResults()
{
$this->session->userdata('user_id');
$userID = $this->session->userdata('userid');
var_dump($userID);
}
If I vardump
the variable in my first controller after session destroy, the variable prints out. However it does not on the second.