I made a website website.org and a subdomain for it subdomain.website.org. On the main domain, I have set up a user login system with a MySQL database. On the main domain, the php code can successfully check whether the user has logged in or not. However, since the registration/login page is inside the main domain directory, the webpages on the subdomain are unable to do the same. How do I make it so that both domains connect to the same database and check for the same account?
You can do this from 4 methods:
Place this in your php.ini:
session.cookie_domain = ".example.com"
Or in your .htaccess:
php_value session.cookie_domain .example.com
Or as the first thing in your script:
ini_set('session.cookie_domain', '.example.com' );
Or in your php-fpm pool configuration for your site:
php_value[session.cookie_domain] = .example.com
you can view here