AuthComponentでログインした後のユーザー情報引き回し
ログインに成功したらユーザー情報ってどこに入るんだろうと思って困惑してたが、ソース追いかけたら分かった。
<?php //auth.php /** * Manually log-in a user with the given parameter data. The $data provided can be any data * structure used to identify a user in AuthComponent::identify(). If $data is empty or not * specified, POST data from Controller::$data will be used automatically. * * After (if) login is successful, the user record is written to the session key specified in * AuthComponent::$sessionKey. * * @param mixed $data User object * @return boolean True on login success, false on failure * @access public */ function login($data = null) { $this->__setDefaults(); $this->_loggedIn = false; if (empty($data)) { $data = $this->data; } if ($user = $this->identify($data)) { $this->Session->write($this->sessionKey, $user); $this->_loggedIn = true; } return $this->_loggedIn; }
auth.phpの$sessionKeyっていうプロパティでSessionに書き込まれているのがすぐわかった。で、それは$userModelのnameの値だよってコメントに書いてある。
ま、とりあえずpr($this->sessionKey)って書いてKeyの名前吐き出してそれメモったほうが早いw