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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:36:09+00:00 2026-05-31T20:36:09+00:00

Hi stackoverflow friends, I have an instance that ,In symfony2 I created a security

  • 0

Hi stackoverflow friends,

I have an instance that ,In symfony2 I created a security bundle (not used FOS USER BUNDLE) in which when I logged in, I try to access the login page again the login form is shown.Is there’s no redirection to the default page, even if I’m actually logged in. How to prevent this login form ,after logged in.

Below is my security.yml

UPDATED

firewalls:
        main:
            pattern: ^/
            anonymous: ~
            form_login:
                login_path: /login
                check_path: /login_check
            logout:
                path: /logout
                target: /login    

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/centerreg, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/customredirect, roles: ROLE_USER }
        - { path: ^/admin/, roles: ROLE_ADMIN }
        - { path: ^/center/, roles: ROLE_CENTER }
        - { path: ^/client/, roles: ROLE_CLIENTADMIN }
        - { path: ^/examcenter/, roles: ROLE_EXAMCENTER }
        - { path: ^/tutor/, roles: ROLE_TUTOR }
        - { path: ^/evaluator/, roles: ROLE_EVALUATOR }
        - { path: ^/student/, roles: ROLE_STUDENT }
        - { path: ^/user/, roles: ROLE_USER }

Any help would be appreciable.

  • 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-05-31T20:36:11+00:00Added an answer on May 31, 2026 at 8:36 pm

    Symfony won’t automatically do this because login page is always accessible as indicated in security.yml:

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    

    If you don’t want authenticated users to get to the login page, you need to manually redirect them away from login page. To do that, go to your Controller for login action and at the beginning of loginAction() function add this:

    public function loginAction()
    {
        if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY'))
        {
            // redirect authenticated users to homepage
            return $this->redirect($this->generateUrl('_homepage'));
        }
    
        //other code goes here...
    }
    

    This will redirect authenticated users to your homepage. Of course, replace ‘_homepage’ to route name of a page you wish to redirect users to.

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

Sidebar

Related Questions

this is my algorithm that I have written it with my friends (which are
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
Hi StackOverflow friends. Running Drupal 6.22 php 5.3 I have been looking around now
Hi friends, Am newbie for windows Development .i have created Grid With tabcontrol using
I realize these questions have been asked before on Stackoverflow, but now that FBML
I'm not sure if this is an appropriate question for StackOverflow. I have a
Hi Stackoverflow friends, I need an appliaction that ,capture an image using camera and
Hello my StackOverflow friends. I have been doing wxPython tutorials and reading the documentation,
Hi stackoverflow coders, I have an app (since the iPhone its really chic 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.