在數據庫中我有用戶名,密碼,身份證,管理等,但我的管理員值不顯示。爲什麼? http://prntscr.com/ewuiz9 http://prntscr.com/ewuj4o會話userdata不顯示管理值
// Get username
$username = $this->input->post('username');
// Get and encrypt the password
$password = md5($this->input->post('password'));
// Login user
$user_id = $this->user_model->login($username, $password);
if($user_id){
// Create session
$user_data = array(
'admin' => $admin,
'user_id' => $user_id,
'username' => $username,
'logged_in' => true
);
$this->session->set_userdata('logged_in', $user_data);
// Set message
$this->session->set_flashdata('user_loggedin', 'You are now logged in');
redirect('posts');
} else {
// Set message
$this->session->set_flashdata('login_failed', 'Login is invalid');
redirect('users/login');
}
}
}
提示:不要使用MD5口令非常不安全的。使用PHP密碼哈希http://php.net/manual/en/function.password-hash.php並驗證http://php.net/manual/en/function.password-verify.php和https:// www.codeigniter.com/user_guide/general/compatibility_functions.html#password_hash – user4419336