0
votes

I recently created a new symfony application on the existing website. Then, in this new application, I want to read the session of old applications(something like login user id). Unfortunately, in each application, the session are completely separate(I mean the symfony session, something like $this->getUser()->getAttribute("userSession")).

I guess the symfony session is implemented using $_SESSION like:

$_SESSION = array("symfonyapp1" => array(....), "symfonyapp2" => array(....));

So I wrote $_SESSION["test"] = "testStr" in the old application and wrote var_dump($_SESSION["test"]);. The screen simply prints "null", so my guess is wrong.

Then I think maybe I can read the configuration of a certain application and then get the user of that application. So I wrote the following code in my new application:

require_once($_SERVER['DOCUMENT_ROOT'].'/../config/ProjectConfiguration.class.php');

$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
$context = sfContext::createInstance($configuration);
var_dump($context->getUser()->getAttribute("userId"));

Unfortunately again, it prints "null".

I completely have no idea now. Any advice is greatly appreciated

1
Did you checked the debug bar (Config/User) it contains all session attributesHaithem Rihane
Thanks a lot for answering. I have checked (Config/User). But in new application page and old application page, The (Config/User) data are completely different, no session attribute is sharedwander

1 Answers

0
votes

Check session identifiers of your apps. Php's default session id is PHPSESSID and as far as I remember default session identifier for Symfony 1.4 apps is just symfony

You can change Symfony's session identifier by modyfing apps/YOUR_APP_NAME/config/factories.yml file, by setting:

all:
  storage:
    param:
      session_name: PHPSESSID

By doing that your Symfony app will share the same session id as your old app and you will be able to read $_SESSION attributes in Symfony app