如何在symfony2中更改用户的全局会话

时间:2015-02-02 14:14:24

标签: php symfony session fosuserbundle

评论转换者会话d'utilisateurconnecteàuneautre session d'utilisateur j'utilise fosuserbundle dans Symfony2

ex:utilisateur connecter us1 转换器会话couranteàus2

1 个答案:

答案 0 :(得分:0)

在security.yml允许切换用户:

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    admin:
        pattern:      /admin(.*)
        form_login:
            provider:       fos_userbundle
            ...
            failure_path:   null
            ...
            ...
        anonymous:    true
        switch_user: true

然后在用户之间切换:

 To switch to another user
 http://example.com/somewhere?_switch_user=UserName
 To switch back to the original user
 http://example.com/somewhere?_switch_user=_exit 

尝试查看symfony文档:http://symfony.com/doc/current/cookbook/security/impersonating_user.html