How do I access a logged in users phone number in cakephp?

限于喜欢 提交于 2020-01-17 03:24:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!