PHP7 + Symfony 2.8, Failed to write session data

前端 未结 4 1230
挽巷
挽巷 2020-12-09 17:12

i compiled php7 on my own (974f6c2a705). if i run php7 + php-fpm + nginx using symfony i get this error:

(using the snc redis bundle for sessions:)

          


        
4条回答
  •  遥遥无期
    2020-12-09 17:50

    If you found this thread because of the error message appearing top of the list in some search results and are not using Symphony - which happened in my case. Make sure the write method of your session handler returns bool - true on success.

    The php session_set_save_handler documentation doesn't mention this. It is however mentioned in the SessionHandlerInterface documentation:

    The return value (usually TRUE on success, FALSE on failure). Note this value is returned internally to PHP for processing.

    In earlier versions of PHP, returning nothing did not result in an error. Since PHP 7.0, returning nothing results in the error: Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp).

    It does look as though future versions of PHP will issue the slightly clearer message. Failed to write session data using user defined save handler.

    If you are using Symphony - then the answer from Chris Banks provides a fuller and more useful solution to the original problem.

提交回复
热议问题