4

I want to access symfony session data from another php page, based in web directory.

I've defined:

$this->getRequest()->getSession()->set('school', 'abc');

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.

2
  • Do you need to get Symfony2 session from a plain php script? Commented Dec 9, 2012 at 17:41
  • Just var_dump the $_SESSION and see what's in there. I guess symfony2 adds some namespace to it's session variables! Commented Dec 10, 2012 at 9:10

1 Answer 1

3

I've solved this problem with this solution:

In config.yml:

framework:
    session:
        save_path: ~

Then I started a session_start(); in a plain php script.

And accessed via:

$_SESSION['_sf2_attributes']['my_value'];

Now, it's ok.

Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to do the reverse elegantly? I know I can use $_SESSION['my_var'] in symfony to get non-symfony session vars, but was wonderng if there's a way using symfony's session object. I've looked, but I don't see a way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.