I want to share a cookie across any subdomain. This should then allow me to keep the session. I am using the Symfony framework version 3.0.
I've read that you should set the following:
## app/config/config.yml
session:
cookie_domain: .localhost
I tried multiple variations on this but none of them change anything. the domain associated with the cookie won't change. Any ideas how this should be done?? What am I missing.
To share cookies across subdomains, you can simply create cookies with the domain directive set to the parent domain, in this case, example.com, rather than either of the specific subdomains.
To share a cookie between domains, you will need two domains, for example myserver.com and slave.com . One of the domains will issue the cookies and the other domain will ask the first domain what cookie should be issued to the client.
That is, if the domain name in your cookie's domain parameter doesn't start with a period, then it will not let subdomains read that cookie. If it does start with the period, then all subdomains will have full access to that cookie's value.
If you set a Domain attribute to the exact subdomain (e.g. application.example.com ), your browser will still interpret it as a wildcard, making the cookie valid for the subdomain and all of its subdomains (as in, it'll show up as .
To be sure you need to delete your cookie and log back.
session:
cookie_lifetime: 0
save_path: %kernel.root_dir%/var/sessions
cookie_domain: .my-domain.com
name: SFSESSID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With