Sunday, July 19, 2015

Symfony - Redirect to a page after login

Method 1:

# vim app/config/security.yml

# app/config/security.yml
security:
    firewalls:
        main:
            form_login:
                default_target_path: /home
                always_use_default_target_path: false

Method 2:

You can also override where the user is redirected to via the form itself by including a hidden field with the name _target_path.

<input type="hidden" name="_target_path" value="/home" />

Reference:

http://symfony.com/doc/current/cookbook/security/form_login.html

No comments: