php - Symfony 5 不处理来自 framework.yaml 文件的会话配置
问题描述
我有 4 个框架文件:
/config/framework.yaml:
framework:
csrf_protection: true
session:
# enables the support of sessions in the app
enabled: true
# ID of the service used for session storage.
# NULL means that Symfony uses PHP default session mechanism
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
# improves the security of the cookies used for sessions
cookie_secure: true
cookie_lifetime: 172800
cookie_httponly: true
cookie_samesite: 'strict'
/config/package/framework.yaml
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
csrf_protection: true
#http_method_override: true
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
cookie_secure: true
cookie_lifetime: 172800
cookie_httponly: true
cookie_samesite: 'strict'
#esi: true
#fragments: true
php_errors:
log: true
\config\routes\dev\framework.yaml
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error
和 /config/packages/test/framework.yaml
framework:
test: true
session:
storage_id: session.storage.mock_file
我看到没有使用 cookie 设置和会话处理程序:例如,创建的 cookie 的生命周期错误,并且会话未存储在 Redis 中。
我通过执行bin/console config:dump-reference framework
命令检查了应用程序状态,我看到定义的配置不存在:
session:
enabled: false
storage_id: session.storage.native
handler_id: session.handler.native_file
name: ~
cookie_lifetime: ~
cookie_path: ~
cookie_domain: ~
cookie_secure: ~ # One of true; false; "auto"
cookie_httponly: true
cookie_samesite: null # One of null; "lax"; "strict"; "none"
use_cookies: ~
gc_divisor: ~
gc_probability: 1
gc_maxlifetime: ~
save_path: '%kernel.cache_dir%/sessions'
# seconds to wait between 2 session metadata updates
metadata_update_threshold: 0
sid_length: ~
sid_bits_per_character: ~
为什么?如何解决?
解决方案
推荐阅读
- python - 在 python 中同时使用 websocket 和 I/O 串行?
- json - 显示带有格式的 WebSocket 消息?
- python - 内存不足:np.meshgrid
- sql - 获取子查询的第一行
- javascript - 在“分子”中将样式化组件“原子”嵌套在一起 -> 样式/定位
- typescript - 使用泛型类型接口泛型类型类
- m2doc - 访问属性模板构造参数的描述属性
- php - 控制器或 FormBuilder 中的 Symfony 3 最大文件大小上传约束
- python - Python Pygame 直接在 Class 中使用 command 或调用 def 会导致不同的效果,为什么?
- powerbi - 如何从列中提取每个不同的名称并使用 Power BI 将其转换为分类变量