【问题标题】:zend session exception on zend_session::start with formszend_session::start 上的 zend 会话异常与表单
【发布时间】:2010-11-28 10:59:40
【问题描述】:

我在尝试使用 Zend_Form_SubForm 和会话时遇到问题。我的控制器本质上是一个向导,根据向导的阶段显示不同的子表单。使用我计划将表单存储在会话命名空间中的示例。

我的控制器看起来像这样。

include 'mylib/Form/addTaskWizardForm.php';

class AddtaskController extends Zend_Controller_Action{

private $config = null;
private $log = null;
private $subFormSession = null;


/**
 * This function is called and initialises the global variables to this object
 * which is the configuration details and the logger to write to the log file.
 */
public function init(){

    $this->config = Zend_Registry::getInstance()->get('config');
    $this->log = Zend_Registry::getInstance()->get('log');

    //set layout
    $this->_helper->layout->setLayout('no-sidemenus');

    //we need to get the subforms and
    $wizardForms = new addTaskWizardForm();        

    $this->subFormSession = new Zend_Session_Namespace('addTaskWizardForms');

    if(!isset($this->subFormSession->subforms)){
        $this->subFormSession->subforms = $wizardForms;
    }

}

/**
 * The Landing page controller for the site.
 */
public function indexAction(){

    $form = $this->subFormSession->subforms->getSubForm('start');


    $this->view->form = $form;
}

但是,这会导致应用程序会话因

而崩溃

带有消息“Zend_Session::start()”的未捕获异常“Zend_Session_Exception”

知道为什么 Zend Session 有问题吗?

谢谢。

【问题讨论】:

  • 完整的异常信息是什么?

标签: php zend-framework session zend-form


【解决方案1】:

确保会话开始前没有空格、换行符或任何其他字符。特别是如果您有包含并且您的 <?php 前面带有空格或从文件的第 2 行开始。

【讨论】:

  • 我无法将您的答案与问题代码相关联。又是哪里改?
【解决方案2】:

这很奇怪,我唯一看到发送类似消息的地方是 Zend/Session.php 的第 435 到 446 行。

您是否尝试通过单元测试运行该代码?请在初始化 Session 之前检查是否没有发送任何标头。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-09
    • 1970-01-01
    • 2011-01-25
    • 1970-01-01
    相关资源
    最近更新 更多