我有一个我想使用的项目,Symfony2.1
当然symfony 1.4
我需要在它们之间与会话共享一些数据,但我不明白为什么会话在它们之间不可见。例如:
在 symfony1 过滤器中,我有:
echo session_id().'<br>';
echo session_name();
$_SESSION['test_s1'] = '123';
var_dump($_SESSION);
结果是:
d30irfcdhjio27uiqd7a52blv7
symfony
array (size=6)
'symfony/user/sfUser/lastRequest' => int 1356289903
'symfony/user/sfUser/authenticated' => boolean false
'symfony/user/sfUser/credentials' =>
array (size=0)
empty
'symfony/user/sfUser/attributes' =>
array (size=0)
empty
'symfony/user/sfUser/culture' => string 'en_US' (length=5)
'test_s1' => string '123' (length=3)
所以,一切看起来都很好。
在 Symfony2 控制器中,我有:
echo session_id() . '<br>';
echo session_name();
$_SESSION['test_s2'] = '123';
$session->set('test_s2_second', '321');
var_dump($_SESSION);
die;
结果:
d30irfcdhjio27uiqd7a52blv7
symfony
array (size=4)
'_sf2_attributes' => &
array (size=4)
'razvan' => string 'test' (length=4)
'_security_secured_area' => string 'C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":777:{a:3:{i:0;N;i:1;s:12:"secured_area";i:2;s:728:"a:4:{i:0;O:41:"Symfony\Component\Security\Core\User\User":7:{s:51:"?Symfony\Component\Security\Core\User\User?username";s:6:"user";s:51:"?Symfony\Component\Security\Core\User\User?password";s:8:"userpass";s:50:"?Symfony\Component\Security\Core\User\User?enabled";b:1;s:60:"?Symfony\Component\Security\Core\User\User?accountNonExpired";b:1;s:64:"?Symfony\Component\Security\Core'... (length=865)
'search_form' => string '' (length=0)
'test_s2_second' => string '321' (length=3)
'_sf2_flashes' => &
array (size=0)
empty
'_sf2_meta' => &
array (size=3)
'u' => int 1356289889
'c' => int 1356287606
'l' => string '0' (length=1)
'test_s2' => string '123' (length=3)
所以,session_id 和 session_name 是相同的,但是我看不到我在 Symfony2 中通过 symfony1 设置的会话的键/值,即使我使用 $_SESSION 也是如此。
背后的架构更复杂,我试图只暴露主要问题。
那么,知道如何将一些变量从 Symfony2.1 设置到会话中并在 symfony 1.4 页面中可见吗?
(我用 Symfony2.0 做了同样的把戏,而且这个把戏奏效了)。