dongziya9863 2014-04-01 13:59
浏览 49
已采纳

Symfony如何隔离应用程序的SESSION值?

I try to understand how Symfony isolate SESSION values of application. I create two files:

// test.php
session_start();
$_SESSION['aaa'] = 111;
var_dump($_SESSION);

and

// test2.php
session_start();
var_dump($_SESSION);

So when I call http://localhost/test.php and then call http://localhost/test2.php, I get same SESSION in both files:

array(1) { ["aaa"]=> int(111) }

But when I add to the end of symfony front controller app_dev.php next code:

var_dump($_SESSION);

and try to call http://localhost/app_dev.php - I get only Symfony session

array(3) { ["_sf2_attributes"]=> &array(0) { } ["_sf2_flashes"]=> &array(0) { } ["_sf2_meta"]=> &array(3) { ["u"]=> int(1396360435) ["c"]=> int(1396360433) ["l"]=> string(1) "0" } }

and I don't get access to the array(1) { ["aaa"]=> int(111) } value, that I expected.

Why? And how can i do mutual session values with this 3 files?

  • 写回答

1条回答 默认 最新

  • doufei8250 2014-04-01 14:23
    关注

    Symfony use NativeFileSessionHandler as default, and all data in this storage will be not expected in another systems.

    As solution, you can create native session handler as service (Class already exists in Symfony/HttpFoundation package) and set this handler to configuration framework.session.handler_id

    For more information, you can see in docs

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

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等