The application has been working perfectly for over two years, only for me not to be able to log into the web app. I discovered that $this->session->set_userdata() is not working. I input my credentials and i get redirected back to the login page. I tried to used an statement on the set_userdata() and found out that it is not working. My code is shown below
/* Autoload.php*/
$autoload['libraries'] = array('database', 'email', 'session');
/* Config.php */
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = BASEPATH.'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
/* Login Controller */
public function verify_login(){
$this->load->library('session');
$pass = $this->input->post('password');
$username = $this->input->post('username');
$action = 'Login';
if($this->admodel->Check_Login_In_DB($username,$pass)){
$sess_array = array();
$sess_array = array(
'uid' => $this->admodel->getUidByUsername($username),
'username' => $username
);
$this->session->set_userdata($sess_array);
$this->admodel->insertLog($action,$this->admodel->getUidByUsername($username));
redirect(base_url(), 'refresh');
}else{
$this->session->set_flashdata('msg','<div style="color:#b94a48;
background-color:#f2dede;border-color:#eed3d7;height:auto;padding:5px;border-radius:3px;margin-bottom:7px;
clear:both">The Email and Password Combination is not found in the database,Check Properly and try again !!!</div>');
redirect(base_url().'login','refresh');
}
}
/* Homepage */
public function index(){
if(!$this->session->userdata('uid')){
$this->session->set_flashdata('msg','<div style="color: #b94a48;background-color:
#f2dede;border-color: #eed3d7;height:auto;padding:5px;border-radius:3px;clear:both;margin-bottom:10px">
You need to signin to continue !!!</div>');
redirect(base_url().'login','refresh');
}
$this->admodel->Check_Login_In_DBreturning true? Otherwise$sess_arraywill be undefined. Everytime the use insert wrong credentials It will generate a warning. What's in your logs? - Felippe Duarte