Frage

I have been sucessfully using the AutoLogin component for a while now and it's great however for some reason I cannot seem to get the _autoLogin function option to work, I need to update the users last_login field when the cookie logs them in.

Has anyone been able to get this to work correctly? No matter what I put it in nothing happens so I assume it is being ignored or not found.

My code is something like this below, I have tried putting it in the AppController, the UserController and the User model, nothing seems to happen.

public function _autoLogin($user) 
{
    debug($user);
    $this->User->id = $user['User']['id']; // target correct record
    $this->User->saveField('last_login', date(DATE_ATOM)); // save login time
}

Thannks

War es hilfreich?

Lösung

It ended up having to go into the AppController.php file.

My new code is as follows:

public function _autoLogin($user) 
{
    //echo $user);
    $this->loadModel('User');
    $this->User->id = $user; // target correct record
    $this->User->saveField('last_login', date(DATE_ATOM)); // save login time
}

This works.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top