我有一个Symfony 3项目,该项目分为 3个应用程序(多个内核,相同的数据库,不同的子域):Front / Admin / Partner。 (主要是为了能够使用几个Sonata Admin配置。)
当用户在Front应用中填写登录表单时,他会重定向到相应的应用(子域名),具体取决于他的角色。
我的问题是:如何在重定向后对其进行身份验证?
答案 0 :(得分:1)
I found why it was not working : my var
folder was split by app therefore my sessions
folder was not shared between apps.
var
|-- admin
| |-- cache
| |-- logs
| |-- sessions
|-- front
| ...
The solution was to define the same save_path
in my apps session configs.
I also had to define the cookie_domain
to hostname (without subdomain) in order to get one PHPSESSID cookie shared by all subdomains :
framework:
session:
save_path: '%kernel.project_dir%/var/sessions/'
cookie_domain: 'mywebsite.com'
答案 1 :(得分:0)
要使其正常工作,我需要在会话部分添加handler_id: session.handler.native_file
并在子域之间共享会话,而我需要在cookie_domain部分中的域之前加一个点作为前缀:
framework:
session:
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/'
cookie_domain: .mywebsite.com