I found this helper code from rob allens' Zend_Auth login/logout tutorial
class Zend_View_Helper_LoggedInAs extends Zend_View_Helper_Abstract
{
public function loggedInAs()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->WSLoginName;
$logoutUrl = $this->view->url(array('controller' => 'login',
'action' => 'logout', 'module' => 'member'), null, true);
return 'Welcome '. $username . '. <a href="'. $logoutUrl . '">Logout</a>';
}
$request = Zend_Controller_Front::getInstance()->getRequest();
$controller = $request->getControllerName();
$module = $request->getModuleName();
$action = $request->getActionName();
if($controller == 'login' && $action == 'index'){
return '';
}
$loginUrl = $this->view->url(array('controller' => 'login', 'action' => 'index'));
return '<a href="'. $loginUrl . '">Login</a>';
}
}
now my question is, how am i gonna use this helper in a different controller, within the same module ?, because apparently, in the said tutorial, this helper is used in a layout file , and then the user gets redirected to the indexController. when user logs out, it gets redirected to the login page again.. my problem is this, I added a new Controller within the same module where the LoginController controller and the said helper resides, and this new controller is using the same layout file where that helper is being called, when I clicked the logout link, it doesn't work anymore