Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp 2.0 how to update auth data?

when I update data in the User model, the Auth data is not updated.

How can I "refresh" the data which is returned by $this->Auth->user() when I am updating user model ?

and I don't want to use

$this->Auth->login($data);

after updating my user table

like image 538
AnNaMaLaI Avatar asked Nov 18 '12 13:11

AnNaMaLaI


2 Answers

I tried the following line. Its works well form me After modify the user data i written the following line

 $this->Session->write('Auth', $this->User->read(null, $this->Auth->User('id')));
like image 171
AnNaMaLaI Avatar answered Sep 23 '22 00:09

AnNaMaLaI


Write the updated data to the Session eg:

$this->Session->write('Auth.User', $data);

Before CakePHP 2.x you can't do this in the model without break the framework design.

With CakePHP 2.x you can load the Session Component from models and update it.

like image 35
Everton Yoshitani Avatar answered Sep 22 '22 00:09

Everton Yoshitani