Starting a session in Zend Framework?
Posted: Sat Mar 07, 2009 3:24 am
When I run the bootstrap setup method in my index file, it gives me this error:
I thought nothing was sent to the browser prior to the front controller dispatch? I can't see where I'm sending ANYTHING to the browser here.
After all the documentation says to start the session in the bootstrap file? The action method and view are empty. When I comment out the Zend_Session::start line, it doesn't produce the error, but rather just an empty page. I don't use any php closing tags anywhere and all my php opening tags are at the very top of the documents.
Here's my Bootstrap file:
And my index:
Thanks for any help you might have
.
Code: Select all
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser; output started in C:\xampp\files\public\index.php/1' in C:\xampp\files\library\Zend\Session.php:419 Stack trace: #0 C:\xampp\files\application\Bootstrap.php(18): Zend_Session::start() #1 C:\xampp\files\public\index.php(6): Bootstrap->setup() #2 {main} thrown in C:\xampp\files\library\Zend\Session.php on line 419After all the documentation says to start the session in the bootstrap file? The action method and view are empty. When I comment out the Zend_Session::start line, it doesn't produce the error, but rather just an empty page. I don't use any php closing tags anywhere and all my php opening tags are at the very top of the documents.
Here's my Bootstrap file:
Code: Select all
class Bootstrap {
public function setup() {
$rootDir = dirname(dirname(__FILE__));
define('ROOT_DIR', $rootDir);
set_include_path(get_include_path()
. PATH_SEPARATOR . ROOT_DIR . '/library');
include 'Zend/Loader.php';
Zend_Loader::registerAutoload();
Zend_Session::start();
$frontController = Zend_Controller_Front::getInstance();
$frontController->addModuleDirectory(ROOT_DIR . '/application/modules');
} // end setup method definition
public function run() {
$frontController = Zend_Controller_Front::getInstance();
$frontController->dispatch();
} // end run method definition
} // end Bootstrap class definitionCode: Select all
require_once('../application/Bootstrap.php');
$bootstrap = new Bootstrap();
$bootstrap->setup();