Sharing SESSION Variables Between Multiple Subdomains
1) the subdomains should use the same path to save session files
2) modify your
php.ini session.cookie_domain = ".example.com"
or .htaccess php_value session.cookie_domain .example.com
or inside of the script ini_set('session.cookie_domain', '.example.com' );
PHP session ids are saved in Cookies. To make a cookie available in all the sub-domains you need to assign it to the root domain. Then all the sub-domains will get the session id from cookie and PHP can find the session using passed session id.
As it turns out, You just need to set the session.cookie_domain
to the root domain in php.ini
file
session.cookie_domain = ".example.com"
Also check manual for different approaches used to set an ini entry.
I found a solution to my problem:
session_name("2620368ghwahw90w");session_set_cookie_params(0, '/', '.mydomain.com');session_start();
This appears to work with no problem. Is this a good method with low security risk?