Reputation: 25
the problem is this, when i login into the project, it creates the session, but when i try to acces the session from other controller, or even from the same controller, the session data doesn't existe, i have loaded session from autoload, and i also tried loading the session in the constructor, but the issue is still there. forgive for my english, this is not my native language, i hope you can help me please, thanks
Controller login function:
public function do_login(){
$user = $this->input->post('usuario');
$passwd = $this->input->post('clave');
$data = $this->login_model->do_login($user,$passwd);
if($data){
$this->session->set_userdata("login",(array)$data);
//print_r($this->session->userdata());
echo json_encode(array('status' => 1,'message'=>'Bienvenido','idPerfil'=> $data->idPerfil));
}else
echo json_encode(array('status' => 0,'message'=>'Usuario o contraseña incorrecto'));
}
constructor
public function __construct(){
parent::__construct();
$this->load->model('login_model');
$this->load->library('Mobile_Detect');
//$this->load->model('cat_usuarios_model');
// $this->load->model('cat_sucursales_model');
$this->load->library("session");
}
this is the autoload.php line
$autoload['libraries'] = array('session','database','form_validation','email');
Upvotes: 0
Views: 1496
Reputation: 8964
Your problem is with configuration.
$config['sess_save_path'] = NULL
This is causing the failure.
If $config['sess_driver'] = 'files';
then $config['sess_save_path']
must be set to an absolute path to the folder where the files will be saved.
You can create a folder for the files. See the documentation for more information. Or, you can use the following.
$config['sess_save_path'] = sys_get_temp_dir();
It is probably better to create a specific folder to save session files than to use sys_get_temp_dir()
. It is a tiny bit more work because setting permissions and ownership of the folder can be tricky if you just learning how to do those things.
Upvotes: 1