PHP7 + Symfony 2.8,无法写入会话数据 [英] PHP7 + Symfony 2.8, Failed to write session data

查看:65
本文介绍了PHP7 + Symfony 2.8,无法写入会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我自己编译了php7(974f6c2a705). 如果我使用symfony运行php7 + php-fpm + nginx,则会出现此错误:

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

(将snc redis捆绑用于会话:)

(using the snc redis bundle for sessions:)

 Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp)

(使用本机会话支持:)

(using the native session support:)

 Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/[...]/app/cache/dev/sessions)

问题似乎与symfony有关,因为php对该文件夹具有读/写访问权限.

the problem seems to be symfony related, because php has read / write access to the folder.

如果我只运行此代码,则无法运行:

if i run nothing but this code, it works:

session_start();
$_SESSION['x'] = 4234;
session_write_close();

symfony为什么无法编写会议的任何建议或想法?

any suggestions or ideas why symfony fails to write the sessions?

推荐答案

PHP7对自定义会话处理程序的会话处理更加严格.无论出于何种原因,Symfony的write方法的自定义会话处理程序都会返回false.以前,这不会触发错误,但现在会触发.

PHP7 is more strict with session handling for custom session handlers. Symfony's custom session handler for its write method is, for whatever reason, returning false. Previously this did not trigger an error but now it does.

由于我们没有太多关于您正在使用的自定义会话处理程序的信息,因此建议您尽可能设置一个不同的自定义会话处理程序,因为它们中的大多数似乎都返回true.

Since we do not have a lot of information on which custom session handler you are using, I would suggest setting a different custom session handler if possible since most of them appear to return true.

这里是不同的会话处理程序Symfony,除了Memcache和WriteCheckSessionHandler之外,大多数似乎显式返回true:

Here are the different session handlers Symfony, most of them appear to explicitly return true except for the Memcache ones and WriteCheckSessionHandler:

https://github.com. com/symfony/symfony/tree/582f4753a343f230fbe18b4e9a0747d48351ddfb/src/Symfony/Component/HttpFoundation/Session/Storage/Handler

由于您提到了Snc Redis Bundle会话处理程序,因此您确定使用的是最新版本吗?一年前对其进行了修改,使其始终在写入时返回true:

Since you mention the Snc Redis Bundle session handler, are you sure you are using the most up-to-date version? A year ago it was modified to always return true on write:

https://github.com/snc/SncRedisBundle/blob/master/Session/Storage/Handler/RedisSessionHandler.php

更新

向PHP提交了一个错误,以查看我们是否可以找出将来版本的更有用的错误消息(请对该错误报告进行投票或发表评论):

Submitted a bug to PHP to see if we can figure out a more useful error message for future versions (please vote or leave a comment on the bug report):

https://bugs.php.net/bug.php?id=71070

这篇关于PHP7 + Symfony 2.8,无法写入会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆