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
-~----------~----~----~----~------~----~------~--~---

Reply via email to