Sometimes, we want to allow PHP sessions to carry over to subdomains.
In this article, we’ll look at how to allow PHP sessions to carry over to subdomains.
How to allow PHP sessions to carry over to subdomains?
To allow PHP sessions to carry over to subdomains, we can make some setting changes.
In php.ini, we can write
session.cookie_domain = ".example.com"
Another way is to change the .htaccess file by writing:
php_value session.cookie_domain .example.com
Or in our script, we write
ini_set('session.cookie_domain', '.example.com' );
Another way is to change our php-fpm pool configuration for our site by writing
php_value[session.cookie_domain] = .example.com
Conclusion
To allow PHP sessions to carry over to subdomains, we can make some setting changes.