如何在cakephp中访问已登录用户的电话号码? [英] How do I access a logged in users phone number in cakephp?
本文介绍了如何在cakephp中访问已登录用户的电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用cakephp 2.8,我想访问已登录用户的电话号码,是否有任何快速方法?无需使用:
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->个人资料
就像一段代码,我可以使用它来获取个人资料表中的用户电话号码
Just a like of code that I can use to get the phone number of a user which is in the profile table.
推荐答案
如果您想在视图中做到这一点,只需执行以下操作:
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')
这篇关于如何在cakephp中访问已登录用户的电话号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文