doudou521125 2012-10-03 08:58
浏览 47
已采纳

为什么Symfony2中的会话数据为空以及如何访问它?

A third-party PHP application stores data in the user's session (using a cookie for PHPSESSID). In this app, the $_SESSION variable contains all this data.

In my Symfony2 application, the same $_SESSION only contains some Symfony data (_sf2_attributes, _security_secured_area, _sf2_flashes, etc.) and I don't see any other data from the other app.

I did a var_dump of the $_SESSION variable in a controller to check this. Using the Symfony Session object shows the same data. The 2 apps use the same domain for storing the PHPSESSID cookie.

How can I get all data of the session in my Symfony app? I would like the session to be shared between the 2 applications.

  • 写回答

1条回答 默认 最新

  • douliang2935 2012-10-03 14:38
    关注

    I finally solved the problem. Symfony stores its session data in its own directory (app/cache/[environment]/sessions). So the solution is to set the default session path in config.yml:

    framework:
        session:
            save_path: ~
    

    This will set the default path back (for example /var/lib/php5 on Linux) and the legacy app session data is made available to the Symfony app.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)