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 8450133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:53:24+00:00 2026-06-10T10:53:24+00:00

Using FOSUserBundle and Symfony2, in my site, depending on the roles of the user

  • 0

Using FOSUserBundle and Symfony2,

in my site, depending on the roles of the user that is logged in, I want to make the Logout to redirect alternatively to two different pages.

So, I want to do something like this:

{% if is_granted("ROLE_PREMIUM") %}
  <a href="{{ path('fos_user_security_logout_premium') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a>
{% else %}
  <a href="{{ path('fos_user_security_logout') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a>
{% endif %}

And then, somehow, do something like this:

<route id="fos_user_security_logout" pattern="/logout">
    <default key="_controller">FOSUserBundle:Security:logout</default>
</route>
<route id="fos_seller_security_logout" pattern="/logoutPremium">
    <default key="_controller">FOSUserBundle:Security:logoutPremium</default>
</route>

But, since all in logout is done in config.yml, putting all this configuration about login and logout, I don’t know how to configure a second trigger and implement it. Actually, the only thing that I want to do is to redirect the user to two different pages according to the role. All the rest should stay the same.

Anything to put around here in security.yml?

        logout:
          path:   /logout
          target: /main/user

Thanks a lot

  • 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-10T10:53:26+00:00Added an answer on June 10, 2026 at 10:53 am

    You can add a CustomLogoutHandler to your security.yml configuration.

    firewalls:
        main: # - the name of your secure area
            logout:
                path:   /logout
                target: /
                success_handler: your_bundle.custom_logout_handler
    

    Where your_bundle.custom_logout_handler would be in charge to logout your user and redirect him according to a similar _target_url parameter for example.

    See Symfony/Component/Security/Http/Logout

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

Sidebar

Related Questions

So first of all i am using FOSUserBundle in Symfony2.1 and that stores my
I installed FOSUserBundle and FOSFacebookBundle using this method : How to make a separate
I am using Symfony2 and I have users and roles already stored in my
i would like to create a new user in FOSUserBundle (Symfony2), but i always
Our application is using Symfony 2.0 and MongoDB with FOSUserBundle for user management. Client
I am using Symfony2 and FOSUserBundle. Just as detailed in the documentation, I have
I'm using Symfony2 and FOSUserBundle. This question is extensible to any other bundled form
I am using FOSUserBundle and FOSUserFacebookBundle to authenticate my users. The issue is that
I'm using FOSUserBundle together with NnmMultiUserBundle. When a user register, using my form_handler, the
I'm using Symfony2 and the FOSUserBundle to manage registration and logins. I'd like to

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.