Skip to content

Instantly share code, notes, and snippets.

@syamn
Last active December 18, 2015 19:09
Show Gist options
  • Save syamn/5831315 to your computer and use it in GitHub Desktop.
Save syamn/5831315 to your computer and use it in GitHub Desktop.
Method to update user sessions after update user model for CakePHP 2.x
<?php
App::uses('AppController', 'Controller');
class SessionsController extends AppController {
var $uses = array('User');
public function update($redirectTo = null) {
$newUser = $this->User->read(null, $this->Auth->user('id'));
$newUser = $newUser['User'];
unset($newUser['password']);
$this->Auth->login($newUser);
if (empty($redirectTo)) $redirectTo = $this->referer();
$this->redirect($redirectTo);
}
public function test(){ debug($this->Auth->user()); exit; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment