zend_session上的zend会话异常::从表单开始
-
07-07-2019 - |
题
我在尝试使用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_Exception',消息'Zend_Session :: start()
知道为什么这会遇到Zend Session的问题?
感谢。
解决方案
确保在会话开始之前没有空格,换行或任何其他字符。特别是如果你有include并且你的<?php
前面有空格或者从文件的第二行开始。
其他提示
这很奇怪,我发现这样的消息发送的唯一地方是Zend / Session.php的第435到446行。
您是否尝试通过单元测试运行该代码?,在初始化会话之前检查是否没有发送任何标头。
不隶属于 StackOverflow