I have a web application using codeigniter with users about 200. If about 100 users login to the system at the same time, sometimes the user logout automatically or redirect to the login page without click logout before.
My Code.
Login Helper (Load in Construst to check login or not)
function is_logged_in()
{
//Get Codeigniter Instance
$obj =& get_instance();
$is_logged_in = $obj->session->userdata('LOGGED_IN');
if(!isset($is_logged_in) || $is_logged_in != true)
{
$obj->session->set_flashdata('message','<div class="error_login"><b>ERROR:</b> Silahkan login terlebih dahulu.</div>');
//If no session, redirect to login page
redirect('login', 'refresh');
}
}
Controller.
public function verify()
{
$username = $this->input->post('username');
$password = $this->input->post('password');
//Query the database
$row = $this->Loginmodel->verify($username,$password);
if (count($row)) {
$dataSession = array(
'userid' => $row->userid,
'role' => $row->role,
'prov_cd' => $row->prov_cd,
'kab_cd' => $row->kab_cd,
'LOGGED_IN'=> true,
'MODAL'=> true
);
$this->session->set_userdata($dataSession);
redirect('dashboard','refresh');
}
else
{
$this->session->set_flashdata('message','<div class="error_login"><b>ERROR:</b> Username atau password salah.</div>');
redirect('login','refresh');
}
}
I think it's because I store many parameters in session data. Thanks.