0

I use the authentification system provided by FOSUser bundle

Everything was doing fine but recently when clicking on :

     <form action="{{ path('fos_user_registration_register') }}" method="post">                          
                           <button class="btn btn-small btn-success" type="submit">S'inscrire</button>                     
     </form>  

that generated the error: The CSRF token is invalid. Please try to resubmit the form.

none of the view nor controller of FOSUserBundle have being modified...!?

How come this happened and how can this be fixed?

1 Answer 1

4

Make sure your twig templates have

{{form_rest(form)}} 

or your php files have

<?php echo $view['form']->rest($form) ?> 

if you specify the individual fields

Sign up to request clarification or add additional context in comments.

2 Comments

thanx...well i ma not sure where to place that {{form_rest(form)}} in {% extends "FOSUserBundle::layout.html.twig" %} {% block fos_user_content %} {% include "FOSUserBundle:Registration:register_content.html.twig" %} {% endblock fos_user_content %}
also, anyone else finding this answer: check how your web server config has changed. I just inflicted this error on myself, and it was because I'd been "improving" the nginx config. In the process, I had switched to a recommended 'try_files $uri $uri/ /app.php$uri;' configuration, but this doesn't include any $args... What does work, is 'try_files $uri $uri/ /app.php$uri$is_args$args;'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.