symfony2:即使我已登录,页面也始终重定向到登录页面

时间:2015-02-17 07:08:30

标签: symfony-2.5

这是我的security.yml文件

    login:
        pattern:  ^/login
        anonymous: ~
        security: true

    main:
        pattern:    ^/
        anonymous: ~
        security: true
        form_login:
            login_path: login
            check_path: login_check
            username_parameter: username
            password_parameter: password
            post_only: true
            always_use_default_target_path: true
            default_target_path: root

        logout:
            path: logout
            target: login

access_control:
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY,methods: [GET] }
    - { path: ^/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY,methods:[POST] }
    - { path: ^/, roles: IS_AUTHENTICATED_FULLY }

登录后,始终重定向到登录页面。请帮我。请参阅下面的图片以获取我的登录凭证 enter image description here

1 个答案:

答案 0 :(得分:0)

http://symfony.com/doc/current/reference/configuration/security.html#reference-security-firewall-context

必须对两个防火墙使用相同的上下文,因为我使用了两个防火墙

 login:
    pattern:  ^/login
    anonymous: ~
    security: true
    context: my_context

main:
    pattern:    ^/
    anonymous: ~
    security: true
    ......
    context: my_context