Reputation: 23
I'm having following Zend Session error with my zend project:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /home/besthomes/public_html/Zend/Session.php(Line:426): Error #2 session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/besthomes/public_html/Zend/Exception.php:1) Array' in /home/besthomes/public_html/Zend/Session.php:432 Stack trace: #0 /home/besthomes/public_html/index.php(47): Zend_Session::start() #1 {main} thrown in /home/besthomes/public_html/Zend/Session.php on line 432
I have wrote this code in bootstrap file:
include('include.php');
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
Zend_Session::start();
i couldn't know the reason for this error. please help to get out of this problem. Thanks.
Upvotes: 2
Views: 3008
Reputation: 8386
Check if you don't have additional characters in your files. For example -
this code won't trigger an error:
<?php
session_start();
but that one will:
(blank line here!)
<?php
session_start();
Same thing applies to included files. But, when you include files you must also notice to do not have additional lines after clossing tag (if you use them). This will work:
<?php
//content of included file
?>
but something like that won't:
<?php
//content of included file
?>
(blank line here!)
(!and here)
So that's why some people consider not using closing tag in php scripts as good practice.
You can also workaround that problem using ob_start
and ob_end_flush
, but like I said - it's workaround, not solution.
Upvotes: 2
Reputation: 6773
Somewhere in your code, there is some output being done, which PHP will send the HTTP headers for. Since the HTTP headers are already sent, they cannot be sent again when trying to start the session. If you want to use sessions, starting the session early or first thing is a good idea.
On the other hand, I've seen this error when my app outputs a separate error, thus sending the HTTP headers.
Please have a look at the docs for further information: http://framework.zend.com/manual/en/zend.session.html
Namely the section called "Starting a Session": http://framework.zend.com/manual/en/zend.session.advanced_usage.html
Tip: Remove/comment out the lines that start the session, and see what is output. There may be another error, even unrelated to your code.
Upvotes: 2