I've been stuck, when I sign up and want to redirect controller to another controller for showing dashboard then that time created session does not working on redirected controller. Here is my sample code.
My Sign up controller :
class Signup extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('admin_model');
$this->load->library('form_validation');
$this->load->helper('cookie');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('string');
$this->load->library('upload');
}
public function index() {
if(!$_POST) {
$this->load->view('web_pages/signup/signup');
} else {
$insert_data = array(
'firstName' => $signup_data['firstName'],
'lastName' => $signup_data['lastName'],
'email' => $signup_data['email'],
'password' => $signup_data['password'],
'phoneNo' => $signup_data['phoneNo'],
'userType' => $signup_data['userType'],
'image' => $image,
'createDate' => date('Y-m-d H:i:s')
);
$this->db->insert('users', $insert_data);
$this->session->set_userdata(array(
'user_id' => $insert_data['email'],
'userType' => $insert_data['userType'],
'status' => TRUE
));
redirect('dashboard'); //another controller.
}
}
}
Below is my dashboard controller
class Dashboard extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('admin_model');
$this->load->library('form_validation');
$this->load->helper('cookie');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('string');
$this->load->library('upload');
}
public function index() {
print_r($_SESSION); die;
}
}
Above dashboard controller doesn't print anything.
Please help me . Thanks in advance.
$signup_datawont have any data in it. use$this->input->post('email')- theEUG$signup_datais not define so it will goes blank then session value also goes to blank that of the reason session is not working - ImBhavin95