Why can't I access symfony session variables from other files?

倖福魔咒の 提交于 2019-12-25 14:00:14

问题


I have an web app built with symfony framework.

I want to merge an symfony app and an codeigniter app without creating a new application using only one framework. So if the user is loged in in symfony it will also be loged in codeigniter

Now i am just trying to access session variables of this symfony app from another php file, but the $_SESSION varible is empty.

(When I print it in this new file, when I print it in symfony files 'controllers, or views' printing it shows session variables correctly).

This newfile.php is in the same domain with symfony app,in the same folder with symfony's index.php, admin.php.

Can anybody help me do this?


回答1:


For Symfony2 when using "composer" the solution is

require_once 'PATH_TO_LIB/vendor/autoload.php';
$symfonySession = new \Symfony\Component\HttpFoundation\Session\Session($app['session.storage']);
$symfonySession->has('someVariable');
...


来源:https://stackoverflow.com/questions/12197713/why-cant-i-access-symfony-session-variables-from-other-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!