【问题标题】:Issue with session.handler.native_file session handler in symfony2symfony2 中 session.handler.native_file 会话处理程序的问题
【发布时间】:2015-11-17 23:11:20
【问题描述】:

我正在使用基于 symfony2 (2.5) 的应用程序遇到一个非常奇怪的问题。

长话短说: 在 config.yml 文件中我有这个:

framework:
  ...
  session:
      name: "a_given_name"

      # THE FOLLOWING LINE CAUSES THE PROBLEM
      handler_id: session.handler.native_file

      save_path: "%kernel.root_dir%/sessions"
      cookie_lifetime: 2629744 #1 month
      gc_maxlifetime: 2629744 #1 month
  ...

会话不起作用! 我检查了所有内容,系统创建了文件,但这些文件始终为空。

将 config.yml 中的“handler_id”条目更改为:“~”一切正常。

framework:
  ...
  session:
      # CHANGING TO THE FOLLOWING -> IT WORKS
      handler_id: ~
  ...

但是,正如文档中所述,“session.handler.native_file”是默认的处理程序......所以它应该可以正常工作......

有什么帮助吗? 非常感谢...

【问题讨论】:

  • 运行php app/console debug:container session.handler.native_file
  • 我已经运行了这个命令php app/console container:debug session.handler.native_file,这是我收到的:[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] The service definition "session.handler.native_file" does not exist. 事实上这个类存在并且它被使用了......我已经调试过了......跨度>

标签: php symfony session nginx


【解决方案1】:

我在运行 Vagrant 机器时遇到了同样的问题。

我建议将会话从同步文件夹(默认 /var/www/html)移到新位置,例如/home/symfony/sessions

framework:
    session:
        handler_id:  session.handler.native_file
        save_path:   "/home/symfony/sessions/%kernel.environment%"

另外,有用的文章: https://coderwall.com/p/h3i5mw/symfony-session-problems-with-vagrant

【讨论】:

  • 谢谢。我会尝试一下,如果有效,我会将其标记为正确答案!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-23
  • 2015-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-11
相关资源
最近更新 更多