1

I controller i can get $_SESSION['my_var'] ( it was created outside of symfony application, and i need to get it inside symfony controller in symfony way e.g.

$Request->getSession()->get('my_var')

But this code always return NULL and if i use $_SESSION['my_var'] i get my result. I have found PHPBridgeSessionStorage class but this not work for me, because my session already started. So question is how can i get it with symfony functions?

1 Answer 1

1

After some research i have found solution:

$_SESSION['_sf2_attributes']['my_var']

So now i can get access to my variable like this:

$Request->getSession()->get('my_var')

Symfony2 Session stores all values per default under a storageKey "_sf2_attributes" (Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag)

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

Comments

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.