how to keep track of currently logged user in zend framework

五迷三道 提交于 2019-12-11 11:59:24

问题


I am a new user for zend framework. For my applications I need to keep track of currently logged in user, to do this I know I have to use zend_Auth and zend_Acl, but I don't know how to do that.


回答1:


Well then the documentation would be the first place for you.

Zend_Auth: http://framework.zend.com/manual/en/zend.auth.html

Zend_Acl: http://framework.zend.com/manual/en/zend.acl.html

To get an easier access you could try this great tutorial series on youtube: http://www.youtube.com/watch?v=UmtGClgImpo which covers every step from auth to acl.


To keep track of something you can use Zend_Registry, e.g.

Zend_Registry::set ( 'role', 'guests' );

and use the auth instance, e.g.

if(Zend_Auth::getInstance()->hasIdentity()){
    Zend_Registry::set('role', Zend_Auth::getInstance()->getStorage()
                                                          ->read()->role);
}else{
    Zend_Registry::set('role', 'guests');
}

But this all is described very well in the tutorial.

Good Luck!



来源:https://stackoverflow.com/questions/5849845/how-to-keep-track-of-currently-logged-user-in-zend-framework

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