Skip to content

Commit 9f3b147

Browse files
ThomasLandauerwouterj
authored andcommitted
Adding that you cannot access a session inside a constructor
1 parent ca7e57e commit 9f3b147

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

session.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ if you type-hint an argument with :class:`Symfony\\Component\\HttpFoundation\\Re
149149
public function __construct(RequestStack $requestStack)
150150
{
151151
$this->requestStack = $requestStack;
152+
153+
// Accessing the session in the constructor is *NOT* reommended, since
154+
// it might not be accessible yet or lead to unwanted side-effects
155+
// $this->session = $requestStack->getSession();
152156
}
153157

154158
public function someMethod()

0 commit comments

Comments
 (0)