"会议已经开始......"异常Zend框架应用程序 [英] "session has already been started...." exception in Zend Framework application

查看:206
本文介绍了"会议已经开始......"异常Zend框架应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到试图加载一个Zend Framework应用程序时,这个错误:

I get this error when trying to load a Zend Framework application:

致命错误:未捕获的异常   Zend_Session_Exception有消息   会话已经开始通过   session.auto启动或在session_start()   在   /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php:462

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

堆栈跟踪:

#0 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session/Namespace.php(143):   过Zend_Session :: start(真)

#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 - > __结构('Zend_Auth的')

#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 - > __构造()

#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()

#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()

#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):   包括:('/网络/ htdocs中/ W00 ...')

#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的 - > _运行('/网络/ htdocs中/ W00 ...')

#6 /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/View/Abstract.php(831): Zend_View->_run('/www/htdocs/w00...')

#7 /网络/ htdocs中/ w00a1ed在/www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php   上线462

#7 /www/htdocs/w00a1ed in /www/htdocs/w00a1ed7/autospin/redaktion/library/Zend/Session.php on line 462

我用 Zend_Auth的和我的本地服务器上,它工作得很好,但在生产服务器上我得到了preceding错误,但不是每一次。

I Use Zend_Auth and on my local server and it works well, but on a production server I get the preceding error, but not every time.

我已经检查了 session.autostart 设置为 0 的.htaccess 文件。

I have checked that session.autostart is set to 0 in the .htaccess file.

如何解决这个问题?

感谢您的回答,但我不是用户在session_start()的任何地方。只有ZF工作。

Thank you for your Answer, but I do not user session_start() anywhere. Work only with ZF.

我有这个问题只有在共享服务器,在我的本地服务器脚本的作品完美。

I Have this Problem only on shared server, on my local server script works perfectly.

我使用的初始化函数与此code:

I Use INIT Function with this code:

保护$用户;

public function init()
{   
    if(!Zend_Auth::getInstance()->hasIdentity())
    {
        $this->_redirect('auth/login');
    }else
    {
        $this->user = Zend_Auth::getInstance()->getIdentity();
    }
}

我媒体链接尝试设置那朵code仅在的indexAction,让其他行动不必CHACK的验证...但还是有问题。

I allready try to set tis code only in indexAction, so that other actions do not have to chack the Auth... but still have problems.

北京时间有没有办法在操作设置为不检查有关会话或somethink这样吗?

Ist there a way to set in an Action to do not check about session or somethink like this?

贝斯特关于

推荐答案

这就是它说,这是。 Zend_Auth的试图启动一个新的会话,因为过Zend_Session :: start()还没有被调用。

It's what it says it is. Zend_Auth tries to start a new session, since Zend_Session::start() has not yet been called.

问题是,过Zend_Session :: start()有一个会话启动之前调用。但是,由于session.autostart为0(顺便说一句,这是中的的php.ini 的没有的的.htaccess 的),你可能已经写在session_start(); 的地方。你不能这样做,因为ZF希望完全控制会话,也就是你不应该直接访问全局会话变量。

The problem is that Zend_Session::start() has to be called before a session is started. But, since session.autostart is 0 (btw this is in php.ini not .htaccess), you have probably written session_start(); somewhere. You're not allowed to do that, since ZF wishes to have full control over sessions, i.e. you shouldn't access the global session variable directly.

要解决这个问题,搜索你的code文件在session_start(),要么

To solve it, search your code files for session_start() and either

  1. 删除所有出现的只有一个。要注意,如果它已经启动,设置使用error_reporting(E_ALL | E_STRICT);
  2. Zend_Session组件更换::开始(); 在所有的地方
  1. remove all occurences but one. To notice if it's already been started, set error_reporting(E_ALL|E_STRICT);
  2. replace it with Zend_Session::start(); at all places

如果你不能找到所有匹配,找到一个在session_start();困扰你的 Zend_Auth的::的getInstance() - > hasIdentity()并解决问题快N'肮脏与下面的代码片断

If you can't find all occurrences, find the one session_start(); that bothers your Zend_Auth::getInstance()->hasIdentity() and solve the problem quick n' dirty with the following snippet

try {
    Zend_Session::start();
} catch(Zend_Session_Exception $e) {
    session_start();
}

如果您使用的是采埃孚在整个应用程序,我会用2去)

If you're using ZF in your whole application, I would go with 2)

这篇关于"会议已经开始......"异常Zend框架应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆