ocorrendo alguns erros, o erro se da quando testo com o metodo hasIdentity()
erro:Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before
any output has been sent to the browser; output started in C:\wwwroot\htdocs\testes\app\controllers\IndexController.php/1'
in C:\wwwroot\htdocs\testes\lib\Zend\Session.php:453 Stack trace: #0 C:\wwwroot\htdocs\testes\lib\Zend\Session\Namespace.php(143):
Zend_Session::start(true) #1 C:\wwwroot\htdocs\testes\lib\Zend\Auth\Storage\Session.php(87): Zend_Session_Namespace->__construct('Zend_Auth')
#2 C:\wwwroot\htdocs\testes\lib\Zend\Auth.php(91): Zend_Auth_Storage_Session->__construct() #3
C:\wwwroot\htdocs\testes\lib\Zend\Auth.php(133): Zend_Auth->getStorage() #4 C:\wwwroot\htdocs\testes\app\views\helpers\LoggedInUser.php(16):
Zend_Auth->hasIdentity() #5 [internal function]: Zend_View_Helper_LoggedInUser->loggedInUser() #6
C:\wwwroot\htdocs\testes\lib\Zend\View\Abstract.php(342): call_user_func_array(Array, Array)
#7 [internal function]: Zend_View_Abstract->__call('loggedInUser', Array)
#8 C:\wwwroot\htdocs\testes\app\views\ in C:\wwwroot\htdocs\testes\lib\Zend\Session.php on line 453
codigo do helper:
- Código: Selecionar tudo
class Zend_View_Helper_LoggedInUser
{
protected $_view ;
public function setView( $view )
{
$this->_view = $view ;
}
public function loggedInUser()
{
$auth = Zend_Auth::getInstance() ;
if ( $auth->hasIdentity() )
{
$logoutUrl = $this->_view->linkTo( 'auth/logout' ) ;
$user = $auth->getIdentity() ;
$username = $this->_view->escape( ucfirst( $user->username ) ) ;
$string = 'Logged in as ' . $username . ' | <a href="' . $logoutUrl . '">Log out</a>' ;
}
else
{
$loginUrl = $this->_view->linkTo( 'auth/identify' ) ;
$string = '<a href="'. $loginUrl . '">Log in</a>' ;
}
return $string ;
}
}
e como chamo na index:
- Código: Selecionar tudo
<?php echo $this->loggedInUser() ; ?>
EDIT: só pra avisar, não estou printando nada na tela antes disso
é isso pessoal, espero que possam me ajudar, abraço!



