从另一个 php 文件访问 Symfony2 会话? [英] Access Symfony2 session from another php file?
本文介绍了从另一个 php 文件访问 Symfony2 会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从另一个基于 web 目录的 php 页面访问 symfony 会话数据.
I want to access symfony session data from another php page, based in web directory.
我已经定义:
$this->getRequest()->getSession()->set('school', 'abc');
并且想要在 web 目录(不是控制器)中存在的另一个 php paged 中获取('school').我在 Google 上搜索了几个小时并尝试了很多替代方案,但都没有成功.
And want to get('school') in another php paged existed in web directory (not a controller). I've searched Google for hours and tried lots of alternatives but couldn't be success.
推荐答案
我已经用这个解决方案解决了这个问题:
I've solved this problem with this solution:
在 config.yml 中:
In config.yml:
framework:
session:
save_path: ~
然后我在一个普通的 php 脚本中启动了一个 session_start();
.
Then I started a session_start();
in a plain php script.
并通过以下方式访问:
$_SESSION['_sf2_attributes']['my_value'];
现在好了.
这篇关于从另一个 php 文件访问 Symfony2 会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文