-
Notifications
You must be signed in to change notification settings - Fork 338
How to check if the user is logged in
Gamempire edited this page Aug 20, 2012
·
18 revisions
Check if the user is logged in (ie: user identity widget)
There are three ways.
ZfcUser provides a View Helper (zfcUserIdentity) which you can use from any view script in your application. Just add the following call to the location in your markup where you want the form to be rendered:
<?php echo $this->zfcUserIdentity(); ?>
You can also get user's fields, like email:
<?php echo $this->zfcUserIdentity()->getEmail(); ?>
The view helper may also return the Authentication Service :
<?php $authService = $this->zfcUserIdentity()->getAuthService(); ?>
<?php echo $this->zfcUserAuthentication()->getIdentity(); ?>
$sm = $app->getServiceManager();
$auth = $sm->get('zfcuser_auth_service');
echo $auth->hasIdentity();
echo $auth->getIdentity()->getEmail();