Reputation: 9373
I am using MultiSite WordPress. I want to set and get common variable in session/cookies for all sites.
My sites are:
NetWrok site:
SubDomain sites are:
and
The problem is when I set session value in "http://www.sitename.com" but not able to get that value in "http://hindi.sitename.com"
and "http://urdu.sitename.com"
Is there any other solution to do this?
Thanks in advance
Upvotes: 0
Views: 1297
Reputation: 19386
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:
Upvotes: 1