2011-02-10 109 views
2

我在下面跟我的Zend的Zend項目會話錯誤:Zend的會話致命錯誤

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 

我已經寫了引導文件的代碼:

include('include.php'); 
include "Zend/Loader.php"; 

Zend_Loader::registerAutoload(); 
Zend_Session::start(); 

我無法知道原因對於這個錯誤。請幫助擺脫這個問題。 謝謝。

回答

2

檢查您的文件中是否沒有其他字符。例如 -
此代碼將不會觸發錯誤:

<?php 
session_start(); 

但人會:

(blank line here!) 
<?php 
session_start(); 

同樣適用於包含的文件。但是,當您包含文件時,您還必須注意在粘貼標籤後沒有附加行(如果使用它們)。這將工作:

<?php 
    //content of included file 
?> 

,但這樣的事情不會:

<?php 
    //content of included file 
?>  
(blank line here!) 
(!and here) 

所以這就是爲什麼有些人認爲not using closing tag in php scripts是很好的做法。

您還可以使用解決方法和ob_startob_end_flush問題,但就像我說的 - 這是解決方法,不解決方案

2

在代碼中的某處,有一些輸出正在完成,哪個PHP將發送HTTP標頭。由於HTTP標頭已經發送,因此在嘗試啓動會話時不能再次發送它們。如果你想使用會議,提前開始會議或第一件事是一個好主意。

另一方面,我看到這個錯誤,當我的應用程序輸出一個單獨的錯誤,從而發送HTTP頭。

請看看的文檔瞭解更多信息: http://framework.zend.com/manual/en/zend.session.html

即所謂的「啓動會話」一節: http://framework.zend.com/manual/en/zend.session.advanced_usage.html

提示: 刪除/註釋掉啓動會話行,看看輸出是什麼。可能還有其他錯誤,甚至與您的代碼無關。

+0

thanx但在我的引導程序文件中添加某種惡意代碼時出現此錯誤,但我已刪除該代碼但我不知道爲什麼此錯誤將作爲相同代碼在引導文件中的某些日期前完美工作。 – Shaily 2011-02-10 06:25:04