Kanishka Panamaldeniya
Kanishka Panamaldeniya

Reputation: 17576

how to keep track of currently logged user in zend framework

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.

Upvotes: 1

Views: 557

Answers (1)

DarkLeafyGreen
DarkLeafyGreen

Reputation: 70416

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!

Upvotes: 2

Related Questions