Php 如何在symfony2中更改用户的全局会话
对“利用率”会议和“利用率”会议的评论 ex:使用我们的连接器us1Php 如何在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:
在您的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切换到另一个用户吗?我发现一个类似的帖子可以帮助你