To get the session in Symfony2 you call the “session” service (in this example, from inside a controller instance):
1 | $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.
Symfony2 & Sessions
More than 3 requests, I'll translate this to Chinese.
超过3个请求,我就会把这篇文章翻译成中文。
No comments:
Post a Comment