Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8152269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:39:36+00:00 2026-06-06T15:39:36+00:00

Symfony2 and FOS User Bundle issue… I have implemented my own login form in

  • 0

Symfony2 and FOS User Bundle issue…

I have implemented my own login form in the head of the page (using FOS User Bundle as per directions in http://forum.symfony-project.org/viewtopic.php?f=31&t=37767.)

Now, I have the error message

Variable "csrf_token" does not exist in ::base.html.twig

Someone else on that forum (url above) had the exact same issue, and resolved it by putting in the hidden csrf field like this

<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />

My problem though is: that works fine when on the /login path, but my whole point is not needing that separate login page, I want my form integrated in the page head always, and it seems that the {{csrf_token}} is only available when the page is rendered by the login controller…

Also, how do I get the error messages (flashes) in there, I assume I must include the login controller in my defaultController somehow, to get all those variables with it every time, or…? Or should I instead render the userBundle controller in that portion of the header instead of pasting some of the userBundle template into my head?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:39:38+00:00Added an answer on June 6, 2026 at 3:39 pm

    If you create your own login form using the Form component then you should already have a csrf token as a hidden field. The reason that the csrf_token variable is available only on /login is because the default FOSUserBundle login controller doesn’t use a form, instead they just generate a csrf token manually as seen here and pass it to the view.

    So, either make sure you are rendering all the hidden fields on your form with something like {{ form_rest(form) }} or generate a csrf_token manually like the FOSUserBundle does here and render it with the code you already have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hard time overwriting labels that the FOS user bundle for Symfony2
I have a symfony 2.1 project using FOSUserBundle. The bundle is installed correctly. All
I am using the FOSUser Bundle for Symfony... My question is; I have two
I am using Symfony2 and I have users and roles already stored in my
I am implementing a dialog for my login form in symfony2, it works well
Using FOSUserBundle and Symfony2, in my site, depending on the roles of the user
I'm using Symfony2 and FOSUserBundle. This question is extensible to any other bundled form
I am using Symfony2 and FOSUserBundle. Just as detailed in the documentation, I have
I have a problem. I have already installed into my Symfony 2 FOS User
I have an example where I am trying to create an AJAX login using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.