I have over two subdomains in my site. such as:www.example.com, login.example.com, user.example.com, cart.example.com...
I setup the cookie_domain
as .example.com
in config.yml
and php.ini
when I setCookies('test', 'value', '.example.com')
, but the cookie is always not shared in the subdomain.
there is my config.yml
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/"
cookie_domain: .example.com
cookie_lifetime: 0
name: TESTSESSIONID
in my security:
security:
session_fixation_strategy: none
i needed this to work for all subdomains, but the domain itself changed depending on whether i was developing or in production.
I use parameters_dev.yml and parameters.yml to define the 'domain', then added this in config.yml to allow cookies accross all subdomains.
framework:
session:
cookie_domain: '.%domain%'
You can configure the session key in the config.yml
defining a cookie_domain. As example:
config.yml
session:
cookie_lifetime: 0
save_path: %kernel.root_dir%/var/sessions
cookie_domain: .my-domain.com
name: SFSESSID
Hope this help
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