We have multiple subdomains: es.mysite.com
, pt.mysite.com
, www.mysite.com
depending upon the language needed.
When we do the following, it creates a cookie
per subdomain, but we want to create a cookie that can be used for all our subdomains.
setcookie('mycookie', 'en', strtotime('+7 day'), '/')
How would i create a cookie
using php7
such that the domain is set to .mysite.com
for the cookie's
domain value?
Current result:
es.mysite.com
, cookie
is create with domain = es.mysite.com
pt.mysite.com
, cookie
is create with domain = pt.mysite.com
Desired Output:
es.mysite.com
, cookie
is create with domain = .mysite.com
pt.mysite.com
, cookie
is create with domain = .mysite.com
Add the main domain to the end like this:
setcookie('mycookie', 'en', strtotime('+7 day'), '/', 'mysite.com');