2013-01-15 17 views
0

我想在重定向到登錄的同一頁面上重定向。 Cake php有函數referer()來使用它。大多數人建議使用它與AUTH Component.But我不使用身份驗證。所以,請幫助我如何使用referer()沒有auth組件。如何使用refere()函數在cakephp中重定向?

+0

這很混亂。你是否要重定向登錄?像'$ this->重定向('/ users/login');'?或者你真的想重定向到引用者? – jeremyharris

回答

0

來自CakePHP文檔。 AuthComponent將通過$ this-> Auth-> redirect()來處理重定向到您向您請求的頁面。

// UsersController.php 

public function login() { 
    if ($this->request->is('post')) { 
    if ($this->Auth->login()) { 
     return $this->redirect($this->Auth->redirect()); 
    } else { 
     $this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth'); 
    } 
    } 
}