從php5.6升級php7.1,報錯php
1 Warning: session_start(): Failed to read session data: user (path: ) 2 3 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /datas/htdocs/test.php:16)
方案:若是是本身寫了 session 處理類,繼承了 SessionHandlerInterface
接口,在 PHP71 中要保證 read
方法,返回的是一個 string
,其餘類型都會報錯。segmentfault
好比個人狀況,在讀不到的時候返回的是 false,在之前版本的 PHP 中,無不良表現,如今要改爲返回空字符串。swoole
轉自:http://www.javashuo.com/article/p-gfjfgucy-nt.htmlcookie
---------------------------------------------------------------2017-08-24------------------------------------------------------------------------session
一、abstract public bool SessionHandlerInterface::write ( string $session_id , string $session_data )php7
返回值不是bool時,報錯:spa
E_WARNING:session_write_close(): Session callback expects true/false return valuecode
E_WARNING:session_write_close(): Failed to write session data using user defined save handler. (session.save_path: )blog
二、出現錯誤:繼承
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /datas/htdocs/root/swoole.php:67)
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /datas/htdocs/root/swoole.php:67)
須要修改對應配置:
ini_set('session.cache_limiter', false);
ini_set('session.use_cookies', false);
PS:參照手冊(session.cache_limiter 指定會話頁面所使用的緩衝控制方法(none/nocache/private/private_no_expire/public)。默認爲 nocache。)設置爲none時依舊報錯