0
我目前使用Auth組件登錄。我想在用戶登錄我的網站時更新用戶表中的last_login字段。如何使用cakephp 2.x中的authcomp更新上次登錄
我在控制器的用戶登錄功能我have--
public function login() {
$this->layout = 'main';
if ($this->request->is('post')) {
if($this->Auth->login()) {
$this->redirect(array('controller'=>'pages','action'=>'dashboard')); // after login , redirect on dahsboard
}
$this->Session->setFlash(__('Your username or password was incorrect.'));
}
$this->redirect(Router::url('/', true)); // there is no login.ctp file so it always redirect on home
}
在應用程序控制器我有
class AppController extends Controller {
public $components = array(
'Auth',
'Session',
);
function beforeFilter() {
$this->Auth->loginAction = array(
'controller' => 'users',
'action' => 'login'
);
$this->Auth->logoutRedirect = array(
'controller' => 'pages',
'action' => 'display','home'
);
}
你是什麼意思 「更新LAST_LOGIN場」?它是上次登錄user_id或日期時間的字段嗎? –