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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?