File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -121,16 +121,17 @@ The following snippet adds CSRF protection to the form factory::
121
121
122
122
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
123
123
use Symfony\Component\Form\Forms;
124
- use Symfony\Component\HttpFoundation\Session\Session ;
124
+ use Symfony\Component\HttpFoundation\RequestStack ;
125
125
use Symfony\Component\Security\Csrf\CsrfTokenManager;
126
126
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
127
127
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
128
128
129
- // creates a Session object from the HttpFoundation component
130
- $session = new Session();
129
+ // creates a RequestStack object using the current request
130
+ $requestStack = new RequestStack();
131
+ $requestStack->push($request);
131
132
132
133
$csrfGenerator = new UriSafeTokenGenerator();
133
- $csrfStorage = new SessionTokenStorage($session );
134
+ $csrfStorage = new SessionTokenStorage($requestStack );
134
135
$csrfManager = new CsrfTokenManager($csrfGenerator, $csrfStorage);
135
136
136
137
$formFactory = Forms::createFormFactoryBuilder()
You can’t perform that action at this time.
0 commit comments