title: Symfony2 twig template is not updated after user registration
body: <p>I have in my symfony2 application a registration modal which is working fine except for the template which is not updated in time but after one refresh.</p>
  <p>When I successfully register in my application, the page is reloaded and I am connected in my app (I can see it in the Symfony debugger) but I can still see the &quot;login&quot; link in my header. and flash messages are not displayed (success or failure are the same).</p>
  <p>Here is the twig code for the header:</p>
  <pre><code>    {% if is_granted(&quot;IS_AUTHENTICATED_REMEMBERED&quot;) %}
          &lt;li&gt;
              &lt;a href=&quot;{{ path('fos_user_security_logout') }}&quot;&gt;
                  &lt;span class=&quot;menulink&quot;&gt;Log out&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
      {% else %}
          &lt;li&gt;
              &lt;a data-toggle=&quot;modal&quot; href=&quot;#registerModal&quot;&gt;
                  &lt;span class=&quot;menulink&quot;&gt;Register&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
      {% endif %}
  </code></pre>
  <p>Here is my <code>registerController</code></p>
  <pre><code>class RegistrationStandardUserController extends Controller
  {
      public function registerAction(Request $request)
      {
              $em = $this-&gt;get('doctrine.orm.entity_manager');
              $user = new StandardUser();
              //Form creation based on my user entity
              $form = $this-&gt;createForm(RegistrationStandardUserType::class, $user);
              
              $form-&gt;handleRequest($request);
              if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
                  $user       -&gt;setEnabled(true);
                  $em         -&gt;persist($user);
                  $em         -&gt;flush();
                  if (!$user) {
                      throw new UsernameNotFoundException(&quot;User not found&quot;);
                  } else {
                      $request-&gt;getSession()-&gt;getFlashBag()-&gt;add('success', 'Félicitation '.$user-&gt;getFirstName().', vous êtes inscrit');
                      $this-&gt;authenticateUser($user);
                  }
              }else if($form-&gt;isSubmitted() &amp;&amp; !$form-&gt;isValid()){
                  $request-&gt;getSession()-&gt;getFlashBag()-&gt;add('error', 'Il y a une erreur dans le formulaire d\'inscription');
              }
          
          return $this-&gt;render('UserBundle:Registration:register.html.twig', array(
                  'form' =&gt; $form-&gt;createView(),
          ));
      }
      
      private function authenticateUser(StandardUser $user)
      {
          $discriminator = $this-&gt;get('pugx_user.manager.user_discriminator');
          $discriminator-&gt;setClass('UserBundle\Entity\StandardUser', true);
          $this-&gt;container-&gt;get('fos_user.security.login_manager')-&gt;loginUser($this-&gt;container-&gt;getParameter('fos_user.firewall_name'),$user);
      }
  }
  </code></pre>
  <p>The modal is inserted like that in my template:</p>
  <pre><code>  &lt;div class=&quot;modal fade&quot; id=&quot;registerModal&quot; role=&quot;dialog&quot;&gt;
      &lt;div class=&quot;modal-dialog modal-lg&quot;&gt;
          &lt;!-- Modal content--&gt;
          {{ render(controller('UserBundle:RegistrationStandardUser:Register', {'request': app.request})) }}
      &lt;/div&gt;
    &lt;/div&gt; 
  </code></pre>
  <p>I can't fine the issue. Could it be the way I insert the form in my template using <code>{{ render(controller('UserBundle:RegistrationStandardUser:Register', {'request': app.request})) }}</code> ?</p>
  <p>I'm using <code>fosUserBundle</code> and <code>pugxMultiUser</code> for the user administration but I'm not sure that is relevant to understand the issue here.</p>