我已在此会话中添加了用户名
if($this->form_validation->run() !== FALSE){
//validation pass
$res = $this->Admin_model->verify_user($this->input->post('email_address'), $this->input->post('password'), $this->_salt);
//if result is true login
if($res !== false){
//person has account
$_SESSION['username'] = $this->input->post('email_address');
现在如何在用户登录后在会话中添加user_id?
答案 0 :(得分:1)
您应该使用像$this->session->set_userdata('user_id', $row['user_id']);
这样的CodeIgniter Session Class忘记原始会话(以及其他全局数组使用)