Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在symfony2中更改用户的全局会话_Php_Symfony_Session_Fosuserbundle - Fatal编程技术网

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

Php 如何在symfony2中更改用户的全局会话,php,symfony,session,fosuserbundle,Php,Symfony,Session,Fosuserbundle,对“利用率”会议和“利用率”会议的评论 ex:使用我们的连接器us1 在您的security.yml允许切换用户中更改会话couranteáus2: firewalls: # disables authentication for assets and the profiler, adapt it according to your needs admin: pattern: /admin(.*) form_login:

对“利用率”会议和“利用率”会议的评论

ex:使用我们的连接器us1
在您的security.yml允许切换用户中更改会话couranteáus2

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文档:

您能用英语试试吗?因此,更多的人可以帮助您。我想将user1的当前会话更改为另一个用户。例如,我与user1连接,我想将全局会话从user1更改为user2,我将作为user2连接。这就是我获取当前用户会话的方式$user=$this->get('security.context')->getToken()->getUser();谢谢你的回答,有可能从controller切换到另一个用户吗?我发现一个类似的帖子可以帮助你