viveka
viveka

Reputation: 193

Symfony4 firewalls logout

Give me some clues to add a logoutlistener in security.yaml of symfony4

Error: The service "security.logout_listener.main" has a dependency on a non-existent service "some.service.id".

In security.yaml

logout:
                path:   /logout
                target: /login
                invalidate_session: false
                delete_cookies:
                    a: { path: null, domain: null }
                    b: { path: null, domain: null }
                handlers: [some.service.id]

Upvotes: 0

Views: 566

Answers (2)

rapaelec
rapaelec

Reputation: 1330

this link can help you , so just don't forget to add your to add controller to have route /logout, and after the firewall can handle automatically your logout when you add this route in your config parameter

Upvotes: -1

viveka
viveka

Reputation: 193

Add these commands

In security.yaml

logout:
                path:   /logout
                target: /
                invalidate_session: true

In controller

    /**
     * @Route("/logout", name="logout")
     */
    public function logout()
    {

    }

In logout button

<a class="text-muted" href="{{ path('logout') }}">logout </a>

Upvotes: 2

Related Questions