Zend_Auth无法写入存储 [英] Zend_Auth fails to write to storage
问题描述
Zend还有另外一件奇怪的令人讨厌的事情.
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);
令我烦恼的是那一刻之后auth-> getIdentity():
What FURIOUSLY annoys me is that the auth->getIdentity() just moments after that:
[idSite] => 0
[urlSite] =>
因此,从这里开始,情况会变得更糟:如果我刷新或该表单的任何其他参数失败,然后将我发送到相同的表单,但没有触摸上面的脚本,则auth-getIdentity()会正确返回:>
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
这意味着代码正确无误,但是如果正确填写了表格,一切都很好地加起来,我将重定向到下一步:$ this-> _ redirect('nextstep'),并且idSite或urlSite都不永远保持空虚.
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.
这是为什么?为什么?
推荐答案
我遇到了同样的问题,我认为最好使用使用会话名称空间功能的途径:
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')
;
这篇关于Zend_Auth无法写入存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!