[eluser]mysterious[/eluser]
I am using CI's session library for loging in/out users in my application. After watching a security tutorial I realized I should use session library with database. So i created a users table in database and set $config['sess_use_database'] = true; in config file.
After doing this change i m not able to log into application. Then I opened user's table in database and realized that user_data field is empty while other fields have data. I used different browsers every time there is an entry in database but no data in user_data field.
my controler code is.
Code:
function checkLogin()
{
$username=$this->input->post('username');
$password=sha1($this->input->post('password'));
$this->db->select('userId, type, username');
$this->db->where(array('username' => $username, 'password'=>$password));
$check=$this->db->get('users')->row_array();
if(count($check)>0)
{
$sessiondata=array('userid'=>$check['userId'],'usertype'=>$check['type'],'username'=>$check['username']);
$this->session->sess_destroy();
$this->session->set_userdata($sessiondata);
redirect('klass');
}
else
echo 'Wrong Username and Password';
}