セッションの情報を新しくするためにログインし直したい場合がある。
そんなときは、
auth component を拡張しちゃうといい。
・auth component
/*
ログインしなおす
*/
function reflesh()
{
$this->__setDefaults();
$session = $this->Session->read($this->sessionKey);
$this->{$this->userModel} = Classregistry::init($this->userModel);
$res = $this->{$this->userModel}->find('first',array('conditions' => array('id' => $session['id'] ,$this->fields['username'] => $session[$this->fields['username']])));
unset($res[$this->userModel][$this->fields['password']]);
$this->Session->delete($this->sessionKey);
$this->Session->write($this->sessionKey,$res[$this->userModel]);
}
で、適当なコントローラーで
$this->Auth->reflesh();
とやればなんとびっくり現在のログイン情報を最新の状態にできる。



