Hello, I'm new to CakePHP. I tried searching for "user last logon" or "last access" in this group, but I don't see any relevant post. Apologies if I didn't read carefully enough!
Question: What's the easiest way to change a field such as "lastlogon" in a user table upon user login? (I thought imitating what edit() is doing would be enough, but...) I'm following the example of Simple User Authentication: http://manual.cakephp.org/chapter/19 Here are some snippets: class AppController extends Controller { ... function checkLogin() { // If the session info hasn't been set... if (!$this->Session->check('User')) { // Force the user to login $this->redirect('/users/login'); } } } class UsersController extends AppController { var $name = 'Users'; var $uses = 'User'; ... function index() { $this->checkLogin(); // force login // user can only read their own record $this->set('data', array('User' => $this->Session->read('User'))); } function login() { // If has submitted form data: if (!empty($this->data)) { $someone = $this->User->findByUsername($this->params['data']['User']['username']); if($someone['User']['password'] == md5($this->params['data']['User']['password'])) { $this->Session->write('User', $someone['User']); $this->set('login_error', false); // change lastlogon value and ip information /* $someone['User']['lastlogon'] = date("Y-m-d G:i:s"); $this->User->save($someone); */ $this->User->saveField('lastlogon', date("Y-m-d G:i:s")); // neither save() or saveField() in the above block works $this->redirect('/users'); } else { $this->set('login_error', true); } } else { $this->set('login_error', false); } } } Field "lastlogon" is of type "datetime". I'm sure this problem is really easy to solve. I just need some idea as to why this code won't work. Any gotchas in my syntax? Thank you for your time! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---
