Ron
Ron

Reputation: 513

Cross subdomain PHPSESSID on localhost

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?

Upvotes: 0

Views: 2107

Answers (1)

invisal
invisal

Reputation: 11181

I believe you need to use session_set_cookie_params to share session across subdomain and you use need to use it on every pages (use it on main domain and subdomain). For example:

session_set_cookie_params(0, '/', '.web.local');    
session_start();

Noted that you need to use it before session_start(). For more information. Read the session_set_cookie_params documentation here.

Upvotes: 3

Related Questions