現在、認証コンポーネントを使用してログインしています。ユーザーがサイトにログインするたびに、users テーブルの last_login フィールドを更新したいと考えています。
私が持っているUsersコントローラーの私のログイン機能--
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'
);
}