Failed to start the session: already started by PHP

sooo here to develop a new Symfony project with the current version of Symvony which is 5.2. i have installed the packages google-mailer, doctrine -fixtures-bundle and webpack-bundle. I’m at the beginning of this project and there to create the first controller which should have a form to login. Controller and From were created with the commands bin/console make:controller and make:form, and not changed. But i already have a problem because i get an error when i call the form

Failed to start the session: already started by PHP.

I can explain this message with the fact that when creating the view Symvony tries to start a session because the form is protected with csrf (which should stay that way). But this should not be a problem because Symvony manages the sessions.

Since i can’t find an answer in the internet i hope to find an answer here.

php.ini => session.auto_start=0;


    secret: '%env(APP_SECRET)%'
    #csrf_protection: true
    #http_method_override: true

    # Enables session support. Note that the session will ONLY be started if you read or write from it.
    # Remove or comment this section to explicitly disable session support.
        handler_id: null
        cookie_secure: auto
        cookie_samesite: lax

    #esi: true
    #fragments: true
        log: true

Test function in HomeController:

     * @Route("/testform", name="testform", methods={"GET","POST"})
    public function testform()
        $User = new User();
        $form = $this->createForm(TestFormType::class, $User);
        if ($form->isSubmitted() && $form->isValid()) {

            return $this->redirectToRoute('home');
        return $this->render('home/testform.html.twig', [
            'form' => $form->createView(),


    public function buildForm(FormBuilderInterface $builder, array $options)

enter image description here

thanks in advance merry christmas and a happy new year

Must go now.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *