PHP Session Across Subdomains

I’m trying to keep the same session alive across subdomains on the same machine. I’ve tried some of the conventional techniques quoted below (placed at the top of the page right after <?php), but none of them work. I know this is possible since I’ve seen it done on other sites, but I just can’t seem to get it to work!

Tried this, didn’t work:

ini_set("session.cookie_domain",substr($_SERVER[HTTP_HOST],3));
session_start();

Also tried this, didn’t work:

session_set_cookie_params(360000,'/','.domain.org');
 session_start();
ob_start();

(where .domain.org is my domain name, with a . before it!)

And, also tried this, didn’t work: :frowning:

session_set_cookie_params(360000,'/','.domain.org');
 session_start();

Please help!

Try this

ini_set("session.cookie_domain", ".mydomain.com");

add it before the session.start() function on any page which creates the session cookie.

Or, you can add:

session.cookie_domain = .mydomain.com

to php.ini

Make sure you’ve cleared your cookies, then try again.

That worked. Thanks! :slight_smile: