Symfony2 & Sessions
To get the session in Symfony2 you call the “session” service (in this example, from inside a controller instance):
$session = $this->get("session");
This will give you a Session object which you can then use to store session data. All the setXXX methods start the session if is not already, so you dont need to call $session->start() most of the time. This class uses inernally a NativeSessionStorage which wraps the classic $_SESSION object. There are other SessionStoreage objects, idk yet how to use them.
Paloma 7:46 AM on 31 January 2012 Permalink |
Thank you, very simple but i couldn’t find it in symfony’s 2 book
Robert 7:02 AM on 21 April 2012 Permalink |
Thank you!
dsafas 4:15 AM on 23 April 2012 Permalink |
sdfafas
Medy 8:42 AM on 24 May 2012 Permalink |
hey , i’m using FOSUserBundle to log my users, and this bundle create a session after the login ,
i want to get the data of my user in the Controller, then print it in the twig.
well if you can explain this to me in general state, cause i’m new to symfony ! thanks for helping