You are just there. Remember that the returned $user array contains the User key, for example:
array( 'User' => array( 'id' => 1 ) )
Thus, saving it in a session under Auth.User actually save the session array as follows:
array( 'Auth' => array( 'User' => array( 'User' => array( 'id' => 1 ) ) ) )
Instead, save it in the Auth key, and you can continue to access it as usual:
$user = $this->User->field('name', array( 'User.id' => $this->Session->read('Auth.User.id') )); $this->Session->write('Auth', $user);
Now that the session keys are cleared, there is a much simpler and faster way to re-enter the userβs system, as mark says in the comments: use $this->Auth->login() .
$user = $this->User->field('name', array( 'User.id' => $this->Session->read('Auth.User.id') )); $this->Auth->login($user);
source share