问题
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