• <bdo id='gBgNJ'></bdo><ul id='gBgNJ'></ul>
  • <legend id='gBgNJ'><style id='gBgNJ'><dir id='gBgNJ'><q id='gBgNJ'></q></dir></style></legend>

    <i id='gBgNJ'><tr id='gBgNJ'><dt id='gBgNJ'><q id='gBgNJ'><span id='gBgNJ'><b id='gBgNJ'><form id='gBgNJ'><ins id='gBgNJ'></ins><ul id='gBgNJ'></ul><sub id='gBgNJ'></sub></form><legend id='gBgNJ'></legend><bdo id='gBgNJ'><pre id='gBgNJ'><center id='gBgNJ'></center></pre></bdo></b><th id='gBgNJ'></th></span></q></dt></tr></i><div id='gBgNJ'><tfoot id='gBgNJ'></tfoot><dl id='gBgNJ'><fieldset id='gBgNJ'></fieldset></dl></div>

    <tfoot id='gBgNJ'></tfoot>

    1. <small id='gBgNJ'></small><noframes id='gBgNJ'>

      1. “会话已经开始……"Zend Framework 应用程序中

        时间:2023-10-02
          <bdo id='9G0fC'></bdo><ul id='9G0fC'></ul>

              <tbody id='9G0fC'></tbody>
          • <i id='9G0fC'><tr id='9G0fC'><dt id='9G0fC'><q id='9G0fC'><span id='9G0fC'><b id='9G0fC'><form id='9G0fC'><ins id='9G0fC'></ins><ul id='9G0fC'></ul><sub id='9G0fC'></sub></form><legend id='9G0fC'></legend><bdo id='9G0fC'><pre id='9G0fC'><center id='9G0fC'></center></pre></bdo></b><th id='9G0fC'></th></span></q></dt></tr></i><div id='9G0fC'><tfoot id='9G0fC'></tfoot><dl id='9G0fC'><fieldset id='9G0fC'></fieldset></dl></div>
            <legend id='9G0fC'><style id='9G0fC'><dir id='9G0fC'><q id='9G0fC'></q></dir></style></legend>

              • <small id='9G0fC'></small><noframes id='9G0fC'>

                  <tfoot id='9G0fC'></tfoot>
                  本文介绍了“会话已经开始……"Zend Framework 应用程序中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在尝试加载 Zend Framework 应用程序时收到此错误:

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

                  致命错误:未捕获的异常带有消息的Zend_Session_Exception"'会话已经由session.auto-start 或 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(true)

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

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

                  #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):包括('/www/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->_run('/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

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

                  我使用 Zend_Auth 并在我的本地服务器上运行良好,但在生产服务器上我收到了前面的错误,但不是每次都如此.

                  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.

                  我已检查 .htaccess 文件中的 session.autostart 是否设置为 0.

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

                  我该如何解决这个错误?

                  How do I fix this error?

                  感谢您的回答,但我不会在任何地方使用 session_start().仅与采埃孚合作.

                  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.

                  我在此代码中使用 INIT 函数:

                  I Use INIT Function with this code:

                  受保护的 $user;

                  protected $user;

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

                  我已经尝试只在indexAction中设置tis代码,这样其他action就不用去破解Auth了...但是还是有问题.

                  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.

                  有没有办法在 Action 中设置不检查会话或类似这样的想法?

                  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.

                  要解决它,请在您的代码文件中搜索 session_start() 和其中之一

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

                  1. 删除所有出现,但只有一个.要注意它是否已经启动,请设置 error_reporting(E_ALL|E_STRICT);
                  2. 在所有地方用 Zend_Session::start(); 替换它

                  如果你不能找到所有的出现,找到一个 session_start();这会困扰您的 Zend_Auth::getInstance()->hasIdentity() 并使用以下代码段快速解决问题

                  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();
                  }
                  

                  如果您在整个应用程序中使用 ZF,我会选择 2)

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

                  这篇关于“会话已经开始……"Zend Framework 应用程序中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Zend 框架 cookie 管理 下一篇:PHP 警告:PHP 启动:无法加载动态库

                  相关文章

                  最新文章

                  • <bdo id='m3AtG'></bdo><ul id='m3AtG'></ul>
                      <i id='m3AtG'><tr id='m3AtG'><dt id='m3AtG'><q id='m3AtG'><span id='m3AtG'><b id='m3AtG'><form id='m3AtG'><ins id='m3AtG'></ins><ul id='m3AtG'></ul><sub id='m3AtG'></sub></form><legend id='m3AtG'></legend><bdo id='m3AtG'><pre id='m3AtG'><center id='m3AtG'></center></pre></bdo></b><th id='m3AtG'></th></span></q></dt></tr></i><div id='m3AtG'><tfoot id='m3AtG'></tfoot><dl id='m3AtG'><fieldset id='m3AtG'></fieldset></dl></div>
                      <tfoot id='m3AtG'></tfoot>

                      <small id='m3AtG'></small><noframes id='m3AtG'>

                      <legend id='m3AtG'><style id='m3AtG'><dir id='m3AtG'><q id='m3AtG'></q></dir></style></legend>