2012-07-07 50 views
1

我对我的CI认证使用ion认证。注册后我遇到了自动登录问题。我没有注册的问题,所有的数据都被插入,我可以登录我的登录表单。但是在用户注册后它不会重定向到主页。离子认证在注册后不会重定向

下面是我的代码。任何人都可以看看吗?

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

您是否检查过错误,例如代码中的通知?在此代码之前启用显示错误并搜索空白/制表符,如果某些输出已经通过重定向使用标题,则通常不会重定向。 – 2012-07-07 22:26:17

+0

没有错误。它实际上重定向,但它重定向到登录页面,我不得不手动登录 – vzhen 2012-07-07 22:40:03

回答

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');  
      } 
+0

IC,谢谢,我想离子寄存器是包含此 – vzhen 2012-07-07 23:03:34