Starting a session in Zend Framework?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Starting a session in Zend Framework?

Post by robincanaday »

When I run the bootstrap setup method in my index file, it gives me this error:

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 419
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:

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 definition
And my index:

Code: Select all

require_once('../application/Bootstrap.php');
 
$bootstrap = new Bootstrap();
$bootstrap->setup();
Thanks for any help you might have :).
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Scratch that.

Post by robincanaday »

Nevermind, it has something to do with the encoding. I could have sworn ALL of my files were encoded the same, apparently not. I'll figure it out.
Post Reply