Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(): Failed opening '/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24
如何解決 php 出現 Warning: session_start() 的錯誤訊息? – unethost無限空間虛擬主機 技術分享部落格

如何解決 php 出現 Warning: session_start() 的錯誤訊息?

php_issue_wp
使用php這類opensource的程式語言,所撰寫的應用程式,當在瀏覽器上執行程式時出現錯誤,通常都會有 error message 可以查看,相當方便於除錯及調整。
我們這次介紹的是,如果跳出Warning: session_start() 開頭的字眼,其實可能影響到的是有三個參數;需要仔細看完完整敘述後,才能真正解掉這個問題。
以下我們介紹的是在程式本身bugs,而改由調整主機的方式。

1.  錯誤訊息的敘述句,出現了下列的訊息:
   Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/xxxxxx/public_html/index.php:1) in /home/xxxxx/public_html/global.php on line 2


其中注意到這一句: output started ,這樣的話,可以查看看 php.ini 的output_buffering 如果是為off,請改設為On之後,在重啟web server,通常就可以解掉。

2.  如果output_buffering=On還是會出現錯誤,則要改調 session.auto_start0 改為 1,在重開 web server試試。


3. 最後還有另一種錯誤訊息,跳出的是:
Warning: session_start() [function.session-start]: open(/tmp\sess_9899cb5ea249708b633fcde3h6fdd0d, O_RDWR) failed:

這時就可以先考慮將 php.ini 的 session.save_path = /tmp 這樣的參數,改到別的路逕去,比方說/home/tmp ;而需要注意的是/home/tmp ,屬性要改為 777 ,否則檔案無法寫入。改掉後,就恢復正常的話,這樣就確定是原先的 /tmp 這個目錄有異常,可能是檔案數太多,超過使用上限引起,也可能是parttion的問題,就要在額外去修復,而這部份,因為不在這一篇主題的內容裡,有機會我們會在介紹。

 

(本篇文章由unethost.com客服人員-Michael完成)

註冊網域請點我。我們提供虛擬主機試用,七天滿意保證,
功能完整使用不受限制,歡迎點我申請。