コントローラーに次のログイン機能があり、ログインの日付/時刻をユーザーデータベーステーブルの DATETIME フィールドである last_login フィールドに保存しようとしています。ログインは正常に機能しますが、フィールドには値が入力されません。これを停止するか、出力を取得する必要があるものをトラブルシューティングする方法は?
public function login() {
$this->layout = 'login';
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->User->id = $this->Auth->user('id'); // target correct record
$this->User->saveField('last_login', date(DATE_ATOM)); // save login time
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Invalid username or password, try again', 'default', array('class' => 'warning'));
}
}