问题
I am using cakephp 2.8, I want to access the logged in users phone number , is there any quick way of doing this? Without using:
$this->User->find(all,conditions);
conditions=array(Authcomponent::user('id')== 'Profile.user_id')
I don't want to use the above code, is there a code like:
$this->AuthComponent::user->profile
Just a like of code that I can use to get the phone number of a user which is in the profile table.
回答1:
If you want to do that in view , just do:
$phone = $this->Session->read('Auth.User.phone');
In case you want this in controller:
$phone = $this->Auth->User('phone')
来源:https://stackoverflow.com/questions/38051022/how-do-i-access-a-logged-in-users-phone-number-in-cakephp