Using session cookies across subdomains is a well known problem: PHP Sessions across sub domains
However if you want to share common informations across your wordpress multisite sites the following may work (as :
$some_name = session_name("shared_multisite_sesssion");
session_set_cookie_params(0, '/', '.sitename.com');
session_start();
Use only cookies for sessions
session.use_only_cookies = 1
session.cookie_httponly = 1
Set the following parameteres in your WordPress config:
define( 'COOKIE_DOMAIN', '.sitename.com' ); // Dot prefix
define( 'COOKIEPATH', '/' );
define( 'COOKIEHASH', md5( 'sitename.com' ) );
However there are a few warnings you should take into account:
- WordPress multisite sites are sometimes independent - as soon as they have their own domain this will not work anymore (Share a cookie between two websites)
- WordPress multisite sites in many setups are intended to be individual sites with similar design. It may not be the best architectural idea to connect those sites via common sessions.