Symfony2 session for all subdomains
The website I am creating has a subdomain for each user. The default domain is www.acme.com, my own page (for example) will be marcel.acme.com. Other user pages are under johndoe.acme.com. Now the following happens: - www.acme.com shows me how logged in. - marcel.acme.com shows me how logged in. - johndoe.acme.com shows me as anonymous.
In my config.yml I have set
A firewall is defined for ^ / and uses both form_login (FosUserBundle) and oauth. Both have the same behavior.
Logging in to www.acme.com does a redirect to marcel.acme.com, so that's probably why both marcel and www work, but how can I get all the subdomains to work?
firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider login_path: /login check_path: /login_check oauth: login_path: /login failure_path: /login check_path: /login use_forward: false default_target_path: /mytracker provider: fos_userbundle resource_owners: facebook: /login/check-facebook oauth_user_provider: service: my_user_provider anonymous: true logout: path: /logout target: /
Symfony version is 2.6.5
source to share
I seem to have managed to solve this. In my config I added:
session: cookie_lifetime: 0 save_path: %kernel.root_dir%/var/sessions cookie_domain: .acme.com name: SFSESSID
Also, I added to my security:
remember_me: key: "%secret%" lifetime: 31536000 path: / domain: .acme.com
This last part is unnecessary. bt I want to implement remember_me function anyway. Thanks for thinking, maybe it helps someone.
source to share