title: Symfony 5 Login form action return Invalid CSRF token
body: <p>I'm using security component of symfony 5 to create authentication system, I used make:auth of symfony cli and I enabled login after register form, when logout and trying to login with login form it return Invalid CSRF token error !</p>
  <p>this is my login form twig :</p>
  <pre><code>{% extends 'base.html.twig' %}
  
  {% block title %}Log in!{% endblock %}
  
  {% block body %}
  
  
  &lt;div class=&quot;container&quot;&gt;
      &lt;br&gt;
  
      &lt;div class=&quot;row justify-content-center&quot; &gt;
  
  &lt;form method=&quot;post&quot;&gt;
      {% if error %}
          &lt;div class=&quot;alert alert-danger&quot;&gt;{{ error.messageKey|trans(error.messageData, 'security') }}&lt;/div&gt;
      {% endif %}
  
      {% if app.user %}
          &lt;div class=&quot;mb-3&quot;&gt;
              You are logged in as {{ app.user.username }}, &lt;a href=&quot;{{ path('app_logout') }}&quot;&gt;Logout&lt;/a&gt;
          &lt;/div&gt;
      {% endif %}
  
      &lt;div class=&quot;card&quot;&gt;
          &lt;article class=&quot;card-body&quot;&gt;
              &lt;a href=&quot;{{ path('app_register') }}&quot; class=&quot;float-right btn btn-outline-primary&quot;&gt;S'inscrire&lt;/a&gt;
              &lt;h4 class=&quot;card-title mb-4 mt-1&quot;&gt;Connection&lt;/h4&gt;
              &lt;p&gt;
                  &lt;a href=&quot;&quot; class=&quot;btn btn-block btn-outline-info&quot;&gt; &lt;i class=&quot;fab fa-twitter&quot;&gt;&lt;/i&gt;   Login via Twitter&lt;/a&gt;
                  &lt;a href=&quot;&quot; class=&quot;btn btn-block btn-outline-primary&quot;&gt; &lt;i class=&quot;fab fa-facebook-f&quot;&gt;&lt;/i&gt;   Login via facebook&lt;/a&gt;
              &lt;/p&gt;
              &lt;hr&gt;
              &lt;form&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;input type=&quot;email&quot; value=&quot;{{ last_username }}&quot; name=&quot;email&quot; id=&quot;inputEmail&quot; class=&quot;form-control&quot; required autofocus&gt;
                  &lt;/div&gt; &lt;!-- form-group// --&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;input type=&quot;password&quot; name=&quot;password&quot; id=&quot;inputPassword&quot; class=&quot;form-control&quot; required&gt;
                  &lt;/div&gt; &lt;!-- form-group// --&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;col-md-12&quot;&gt;
                          &lt;div class=&quot;form-group&quot;&gt;
                              &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary btn-block&quot;&gt; Login  &lt;/button&gt;
                          &lt;/div&gt; &lt;!-- form-group// --&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt; &lt;!-- .row// --&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;col-md-12 mt-5&quot;&gt;
                          &lt;a href=&quot;{{ path('app_forgot_password_request') }}&quot; class=&quot;small&quot;&gt;Mot de passe oubliée&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;checkbox mb-3&quot;&gt;
                      &lt;label&gt;
                          &lt;input type=&quot;checkbox&quot; name=&quot;_remember_me&quot;&gt; Remember me
                      &lt;/label&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/article&gt;
      &lt;/div&gt;
  &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  <hr />
  <pre><code>/**
       * @Route(&quot;/login&quot;, name=&quot;app_login&quot;)
       * @param AuthenticationUtils $authenticationUtils
       * @return Response
       */
      public function login(AuthenticationUtils $authenticationUtils): Response
      {
          // if ($this-&gt;getUser()) {
          //     return $this-&gt;redirectToRoute('target_path');
          // }
  
          // get the login error if there is one
          $error = $authenticationUtils-&gt;getLastAuthenticationError();
          // last username entered by the user
          $lastUsername = $authenticationUtils-&gt;getLastUsername();
  
          return $this-&gt;render('security/login.html.twig', ['last_username' =&gt; $lastUsername, 'error' =&gt; $error]);
      }
  </code></pre>
  <p>I don't understand how login system work directly after register form but it doesn't on login action</p>