I am on Windows 7 using WAMP, and I am trying to share the PHPSESSID across subdomains.
In my code I set: ini_set('session.cookie_domain', '.web.local');
When I go to test.web.local I get a different PHPSESSID than web.local
I want to be able to share the PHPSESSID in $_COOKIE accross the subdomains.
What am I doing wrong?
- Also running Wildcard based subdomains via Acrylic DNS Proxy custom hosts file.
- Another thing, if I
echo phpinfo()on both domains, thesession.cookie_domaindirective has the same value on both.
I believe you need to use
session_set_cookie_paramsto share session across subdomain and you use need to use it on every pages (use it on main domain and subdomain). For example:Noted that you need to use it before
session_start(). For more information. Read the session_set_cookie_params documentation here.