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 依据报错在原代吗格式的基础上解决问题
  • ¥15 在虚拟机中安装flash code
  • ¥15 单片机stm32f10x编写光敏电阻调节3.3伏大功率灯亮度(光强越大灯越暗,白天正常光强灯不亮,使用ADC,PWM等模块)望各位找一下错误或者提供一个可实现功能的代码
  • ¥20 verilog状态机方法流水灯
  • ¥15 pandas代码实现不了意图
  • ¥15 GD32H7 从存储器到外设SPI传输数据无法重复启用DMA
  • ¥25 LT码在高斯信道下的误码率仿真
  • ¥45 渲染完成之后将物体的材质贴图改变,自动化进行这个操作
  • ¥15 yolov5目标检测并显示目标出现的时间或视频帧
  • ¥15 电视版的优酷可以设置电影连续播放吗?