Zend_Auth 无法写入存储
Zend 还发生了另一件奇怪而烦人的事情。
基本上,创建用户域后我有以下代码:
$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() 就在那之后:
[idSite] => 0
[urlSite] =>
所以从这里开始情况变得更糟:如果我刷新或者如果任何其他参数表单失败并将我发送到相同的表单,但无需触摸上述脚本,auth-getIdentity() 就会正确返回:
[idSite] => 2431
[urlSite] => exampledomain
这意味着代码正确且有效,但如果表单填写正确并且所有内容加起来都很好,我重定向到下一步:$this->_redirect('nextstep'),并且 idSite 或 urlSite 都不会永远保持为空。
这是为什么呢?为什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,我认为最好通过使用会话命名空间功能的途径:
并且您可以通过以下方式恢复数据:
这里还有更多线索: Zend_Auth 其主要信息是Zend_Auth数据的存储是实际上只是一个命名空间。
对此的默认访问类似于:
$oSession = new Zend_Session_Namespace('Zend_Auth')
;I've had the same issue and I think it is better to go via the route of using the session namespace functionality:
And you can recover the data by:
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 不写入存储的问题。然而,在看到伊恩·刘易斯的答案和你的回应后,我意识到它可能写得很好,但没有阅读。我之前已将会话中的“名称”设置更改为我自己的命名空间。一旦我删除了它并再次开始使用默认值,我的 Zend_Auth 就可以正常工作了。
I also had trouble with Zend_Auth not writing to storage. However, after seeing the answer by Ian Lewis and your response I realised it was probably writing ok, but not reading. I had previously changed the 'name' setting in my session to my own namespace. Once I removed this and started using the default again my Zend_Auth worked fine.