Authentication Symfony2 FosUser:CSRF令牌问题

Authentication Symfony2 FosUser:CSRF令牌问题,authentication,symfony,csrf,fosuserbundle,Authentication,Symfony,Csrf,Fosuserbundle,我使用FOSUser bundle提供的身份验证系统 一切正常,但最近点击: <form action="{{ path('fos_user_registration_register') }}" method="post"> <button class="btn btn-small btn-success" type="submit">S'inscrire

我使用FOSUser bundle提供的身份验证系统

一切正常,但最近点击:

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

S'inscrire
产生错误的原因:CSRF令牌无效。请尝试重新提交表单

FOSUserBundle的视图和控制器均未被修改


为什么会发生这种情况?如何修复这种情况?

确保您的小树枝模板

{{form_rest(form)}} 
或者您的php文件

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


如果指定单个字段

请确保您的细枝模板具有

{{form_rest(form)}} 
或者您的php文件

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


如果指定单个字段

thanx…那么我不确定将{{form_rest(form)}放在{%extends“FOSUserBundle::layout.html.twig”%}{%block fos_user_content%}{%include“FOSUserBundle:Registration\u content.html.twig”}{%endblock fos_user_content%}中的哪个位置,其他找到这个答案的人:检查您的web服务器配置是如何更改的。我只是在自己身上犯了这个错误,这是因为我一直在“改进”nginx配置。在这个过程中,我切换到了推荐的“try_files$uri$uri//app.php$uri;”配置,但这不包括任何$args。。。工作原理是“try_files$uri$uri//app.php$uri$is_args$args;”thanx…我不知道把{{form_rest(form)}放在哪里{%extends“FOSUserBundle::layout.html.twig”}{%block fos_user_content%}{%include“FOSUserBundle:Registration:register_content.html.twig”}{%endblock fos_user_content%}还有,其他找到这个答案的人:检查您的web服务器配置是如何更改的。我只是在自己身上犯了这个错误,这是因为我一直在“改进”nginx配置。在这个过程中,我切换到了推荐的“try_files$uri$uri//app.php$uri;”配置,但这不包括任何$args。。。工作原理是“try_files$uri$uri//app.php$uri$is_args$args;”