How can using subdomains affect session management and lead to the creation of new SessionIDs in PHP?

When using subdomains in PHP for session management, each subdomain is treated as a separate entity by default, leading to the creation of new SessionIDs for each subdomain. To solve this issue and have a single SessionID across all subdomains, you can set the session cookie domain to the root domain using the session.cookie_domain configuration in your PHP code.

// Set the session cookie domain to the root domain to allow sharing of SessionIDs across subdomains
ini_set('session.cookie_domain', '.yourdomain.com');
session_start();