【发布时间】:2011-01-25 23:07:20
【问题描述】:
尝试加载 Zend Framework 应用程序时出现此错误:
致命错误:未捕获的异常 带有消息的“Zend_Session_Exception” '会话已经由 session.auto-start 或 session_start()' 在 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php:462
堆栈跟踪:
#0 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session/Namespace.php(143): Zend_Session::start(true)
#1 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Auth/Storage/Session.php(87): Zend_Session_Namespace->__construct('Zend_Auth')
#2 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Auth.php(91): Zend_Auth_Storage_Session->__construct()
#3 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Auth.php(141): Zend_Auth->getStorage()
#4 /www/htdocs/w00a1ed7/autospin/redaktion/application/layouts/scripts/layout.phtml(31): Zend_Auth->hasIdentity()
#5 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/View.php(108): 包括('/www/htdocs/w00...')
#6 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/View/Abstract.php(831): Zend_View->_run('/www/htdocs/w00...')
#7 /www/htdocs/w00a1ed 在 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php 第 462 行
我在本地服务器上使用Zend_Auth,它运行良好,但在生产服务器上,我得到了前面的错误,但不是每次都出现。
我检查了session.autostart 在.htaccess 文件中设置为0。
如何解决这个错误?
感谢您的回答,但我不在任何地方使用 session_start()。仅与 ZF 合作。
我只在共享服务器上遇到此问题,在我的本地服务器脚本上运行良好。
我在这段代码中使用 INIT 函数:
受保护的 $user;
public function init()
{
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('auth/login');
}else
{
$this->user = Zend_Auth::getInstance()->getIdentity();
}
}
我已经尝试只在 indexAction 中设置 tis 代码,这样其他操作就不必破解 Auth...但仍然有问题。
有没有办法在 Action 中设置不检查会话或类似这样的想法?
最好的问候
【问题讨论】:
-
我有时也会收到此错误...解决方案会很好:)
-
我能想到两件事让 live-&dev-servers 显示不同的结果:1) 不完全相同的文件;或 2) 不同的配置
-
或不同的服务器设置......
标签: php zend-framework session .htaccess zend-auth