尝试加载 Zend Framework 应用程序时出现此错误:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' in /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php:462
Stack trace:
#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): include('/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 in /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php on line 462
我使用 Zend_Auth
并在我的本地服务器上运行良好,但在生产服务器上我收到上述错误,但并非每次都如此。
我已检查 .htaccess
文件中的 session.autostart
是否设置为 0
。
如何修复此错误?
<小时/>谢谢您的回答,但我不在任何地方使用 session_start() 。仅与采埃孚合作。
我仅在共享服务器上遇到此问题,在我的本地服务器脚本上完美运行。
我将 INIT 函数与此代码一起使用:
protected $用户;
public function init()
{
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('auth/login');
}else
{
$this->user = Zend_Auth::getInstance()->getIdentity();
}
}
我已经尝试仅在indexAction中设置此代码,以便其他操作不必检查身份验证...但仍然有问题。
有没有办法在操作中设置不检查 session 或类似的事情?
最诚挚的问候
最佳答案
在这让你发疯之前,你的代码可能没有任何问题!
检查你的 application.ini 中的 session 保存路径,对我来说是 APPLICATION_PATH '/ session '
现在检查您是否拥有正确的权限! 如果没有,则 cd 进入应用程序文件夹并输入
sudo chmod 777 session sudo chown -R [usernamehere] session sudo chgrp -R [usernamehere] session
工作完成!
关于php - Zend Framework 应用程序中的 "session has already been started...."异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2418124/