At another page, you don't set the session namespace object into the registry.
The registry has to be setup every time there is a page request. If you don't
set the session namespace into the registry, then you can't access it. So
create a plugin, resource or whatever where you do the same thing you're
already doing at the auth action :)
Regards, Jurian
PS. Did you know about the Zend_Auth::getInstance()->hasIdentity()?
--
Jurian Sluiman
Soflomo.com
Op Tuesday 23 June 2009 15:42:10 schreef KimG:
> hi,
>
> i'm making an application in which the user have to logon in order to get
> access to the real 'goodies'.
>
> in my authentication action in my index controller i'm doing this when the
> user is verified:
>
> $sesuser = new Zend_Session_Namespace('user');
> Zend_registry::set('user', $user);
> return true;
>
> which means that i store the user info in the registry.
>
> in my welcome page i use this in order to show the username to the user
> when logged in:
>
> echo Zend_registry::get('user')->username
>
> and it works. i see the correct username dispayed.
>
> when the user click the forward link he's redirected to another controller:
>
> GameController
>
> in the init of this i do:
>
> $registry = Zend_Registry::getInstance();
> // print_r($registry);
> try{
> echo Zend_registry::get('user')->username;
> }
> catch (Exception $e){
> echo "YOU'RE NOT LOGGED IN ".$e;
> $this->_redirect('/');
> }
>
>
> but no matter what i do, it fails. I would expect the 'user' object to
> exist in the registry at this point since i've already accssed it in my
> welcome page like this.
>
> but it fails.
>
> if i use print_r($registry) in my welcome page i can se the user object it
> contains. but if i write out the registry in my GameController init()
> function it seems to have disappeared.
>
> what am i doing wrong?
>
> looking forward to any help.
>
> thanks.
>
> kim