If you print_r($this->Auth), what keys/values are included in the array?
On May 18, 4:09 am, paulos nikolo <paulitosthe...@gmail.com> wrote: > Yeah Andy i tried this but still nothing.Dunno what else i have to do.Thx > anyway for your idea! > > 2009/5/18 andy <andy.baugh...@gmail.com> > > > > > I may be wrong, but I believe '$this->Auth->user()' would look for the > > function 'user()' within Auth rather than an array value. Have you > > tried '$this->Auth->user['id']' before calling saveField? > > > On May 17, 5:43 am, paulos nikolo <paulitosthe...@gmail.com> wrote: > > > Still nothing Faza.I am wondering if i have to do something else to get > > it > > > work.I think --> if ($this->Auth->user()) doesnt seem to work.If i erase > > > this line cake save the last_login but in a new row. > > > > 2009/5/16 Faza <f...@ansi.pl> > > > > > This is the code I'm using, works 100%. > > > > > function login() { > > > > $this->layout = 'login'; > > > > if ($this->Auth->user()) { > > > > $this->User->id = $this->Auth->user('id'); > > > > $this->User->saveField('last_visit', 'now()'); > > > > $gr = > > > > $this->User->Group->findById($this->Auth->user('group_id')); > > > > $this->Session->write('Auth.User.group', > > $gr['Group']['name']); > > > > $this->Session->write('Auth.User.password', ""); > > > > $this->redirect($this->Auth->redirect()); > > > > } > > > > } > > > > > Paulos23 pisze: > > > > > Hi Cake people, > > > > > I have spent much time in make this work but nothing.I am using auth > > > > > which is working ok and i want to update the last_login field in > > users > > > > > table.But i can't.Most of my attempts lead to create a new row in > > > > > table with an empty user contained the updated field.I have read all > > > > > of the previous posts here but nothing help me.Can you tell me if I > > > > > do something wrong.Here i put my code: > > > > > > app_controller: > > > > > > class AppController extends Controller { > > > > > var $components = array('Auth'); > > > > > function beforeFilter() { > > > > > $this->Auth->loginAction = array('controller' => > > 'users', > > > > 'action' > > > > > => 'login'); > > > > > $this->Auth->logoutRedirect = array('controller' => > > > > 'users', > > > > > 'action' => 'login'); > > > > > $this->Auth->loginRedirect = array('controller' => > > 'users', > > > > 'action' > > > > > => 'index'); > > > > > $this->Auth->loginError=__('Invalid username or > > > > password',true); > > > > > $this->Auth->authorize='controller'; > > > > > } > > > > > > function isAuthorized(){ > > > > > return true; > > > > > } > > > > > } > > > > > > users_controller: login action > > > > > > function login() { > > > > > $this->layout ='user_login'; > > > > > if ( $this->Auth->user() ) { > > > > > $user = $this->Auth->user(); > > > > > > $this->User->id = > > > > $this->Auth->user('id'); > > > > > //$user['User']['last_login'] = date ( 'Y-m-d > > > > > H:i:s' ); > > > > > $this->User->saveField('last_login', > > > > date('Y-m-d > > > > > H:i:s')); > > > > > //$this->User->save('$user'); > > > //$this->User->last_login = > > > > date("Y-m-d H:i:s"); > > > > > } > > > > > > } > > > > > > When i have if ( $this->Auth->user() ) { > > > > > $user = $this->Auth->user(); > > > > > in my code nothing happened.If i comment it then the new row will be > > > > > added. > > > > > Any help would be so nice! > > > > > ty in advance,Paulos --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---