Reputation: 3
I have a small site hosted, and I know how to get the session data of a user that's logged in, but lets say I have two different users that login to the site how can I store that into a global like $_SESSION['userName'];
So What's happening right now is that, if I get the session data from a logged in user it only returns that user. If this makes sense.
public function login_user()
{
$user_login=array(
'email'=>$this->input->post('user_email'),
'password'=>sha1($this->input->post('user_password'))
);
$data=$this->User_model->login_user($user_login['email'],$user_login['password']);
if($data)
{
$this->session->set_userdata('userName',$data['userName']);
$this->session->set_userdata('email',$data['email']);
$this->load->view('user_profile.php',$data);
}
else
{
$this->session->set_flashdata('error_msg', 'Error occured,Try again.');
$this->load->view('login.php');
}
}
Upvotes: 0
Views: 687
Reputation: 71
You can set only one user can login at a time in one browser. If you need to login with another user account you must need to open in another browser. May be if you need to know how may users logged in
application/config/config.php file:
set sess_driver option as database.
Make sure you have import the ci_session table.
FYI: https://www.codeigniter.com/user_guide/libraries/sessions.html
Upvotes: 2