我正在使用ion auth进行CI身份验证。注册后我遇到自动登录问题。我对注册表没有任何问题,所有数据都已插入,我可以使用我的登录表单登录。但在用户注册后,它不会重定向到主页。
下面是我的代码。有人可以看看吗?
if ( $this->form_validation->run() == TRUE )
{
//if form validation not false, password var
$username = $this->input->post('email');
$password = $this->input->post('password');
$email = $this->input->post('email');
$additional_data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
);
}
if ($this->form_validation->run() == TRUE && $this->ion_auth->register($username, $password, $email, $additional_data))
{
//check to see if we are creating the user
//redirect them back to the home page
$this->session->set_flashdata('msg', "User Created");
redirect("auth/home", 'refresh');
}
else
{
$this->session->set_flashdata('msg', validation_errors('<div>','</div>'));
redirect('auth/index','refresh');
}
答案 0 :(得分:3)
这是因为用户“已注册”但他们没有“登录”。您需要在注册之后但在重定向之前手动登录它们。
if ($this->form_validation->run() == TRUE && $this->ion_auth->register($username, $password, $email, $additional_data))
{
//check to see if we are creating the user
//redirect them back to the home page
$this->session->set_flashdata('msg', "User Created");
// ***DO MANUAL LOGIN HERE WITH ION_AUTH***
redirect("auth/home", 'refresh');
}