tags:

views:

126

answers:

1

I have yet another weird annoying thing going on with Zend.

Basically, I have the following code after creating a user domain:

$this->auth = Zend_Auth::getInstance();
$this->view->user = $this->user = $this->auth->getIdentity();
$this->user->idSite = $idSite;
$this->user->urlSite = $urlSite;
$this->auth->getStorage()->write($this->user);

What FURIOUSLY annoys me is that the auth->getIdentity() just moments after that:

[idSite] => 0
[urlSite] =>

So from here it gets worse: If I REFRESH or if any of the other parameters of the form fail and send me to the SAME FORM, but WITHOUT TOUCHING THE ABOVE SCRIPT, the auth-getIdentity() correctly returns:

[idSite] => 2431
[urlSite] => exampledomain

Which means that the code is correct and working, BUT if the form is filled out correctly and everything adds up nicely, I redirect to the next step: $this->_redirect('nextstep'), and neither idSite or urlSite remain empty forever.

Why is this? Why?

A: 

I've had the same issue and I think it is better to go via the route of using the session namespace functionality:

$oSession = new Zend_Session_Namespace('myStorage');
$oSession->foo = "bar";
$oSession->baz = 123;

And you can recover the data by:

$oSession = new Zend_Session_Namespace('myStorage');
$this->view->foo = $oSession->foo;

There are some more clues here: Zend_Auth the main message of which is that the storage of Zend_Auth data is actually just a namespace.

The default access to this would be similar to :

$oSession = new Zend_Session_Namespace('Zend_Auth');

Ian Lewis
Very interesting - thank you.
John