File tree 1 file changed +11
-2
lines changed
components/http_foundation
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,16 @@ object-oriented interface using a variety of session storage drivers.
12
12
Sessions are used via the simple :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Session `
13
13
implementation of :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ SessionInterface ` interface.
14
14
15
+ .. caution ::
16
+
17
+ Make sure your Sessions aren't already initliazed (which in Symfony is done automatically),
18
+ as initializing the Session object causes the session to be started, which can lead to unexpected errors.
19
+
15
20
Quick example::
16
21
17
- $session = $this->getRequest()->getSession();
22
+ use Symfony\Component\HttpFoundation\Session\Session;
23
+
24
+ $session = new Session();
18
25
$session->start();
19
26
20
27
// set and get session attributes
@@ -287,7 +294,9 @@ to be used for more complex messaging in your application.
287
294
288
295
Examples of setting multiple flashes::
289
296
290
- $session = $this->getRequest()->getSession();
297
+ use Symfony\Component\HttpFoundation\Session\Session;
298
+
299
+ $session = new Session();
291
300
$session->start();
292
301
293
302
// add flash messages
You can’t perform that action at this time.
0 commit comments