2012-07-07 51 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