0

My subdomains redirect alls in the main domain . I am the admin. We can access to my website by the main domain or subdomain. I use that to share cookies between domain and subdomain : There is no difference if I let empty ADMIN_COOKIE_PATH, COOKIEPATH, and SITECOOKIEPATH.

define('ADMIN_COOKIE_PATH', $_SERVER['HTTP_HOST']);
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
define('COOKIEPATH', $_SERVER['HTTP_HOST']);
define('SITECOOKIEPATH', $_SERVER['HTTP_HOST']);

Currently all subdomains have access to same cookies as main domain but they can't read these.

I read in other stackoverflow post that I must add a period cookie. But the main domain doesn't need a period to be allowed to read cookies ! The wordpress_test_cookie has the same value in domain and subdomain . the cookies set on domain and subdomain : wordpress_logged_in_, wordpress_sec_, wordpress_test_cookie and wp_lang.

This function wp_get_current_user() doesn't return user informations on subdomain but well return for main domain.

More information : I defined WP_HOME depending of $_SERVER['HTTP_HOST'): switch ( $_SERVER['HTTP_HOST'] ) { case 'suddom.website.com': define( 'WP_HOME', 'https://suddom1.website.com/' ); break; case 'visiter.activus.city': define( 'WP_HOME', 'https://suddom2.website.com/' ); break; case 'habiter.activus.city': define( 'WP_HOME', 'https://suddom3.website.com/' ); break; default: define( 'WP_HOME', 'https://website.com/' ); } define('WP_SITEURL', WP_HOME);

can this cause a problem to allow wordpress to authorize subdomain to access and read user informations ?

1 Answer 1

0

I resolved my problem using that: (edited

define('ADMIN_COOKIE_PATH', '/wp-admin');
define('COOKIE_DOMAIN', '.website.com');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', '.website.com');
define('COOKIEHASH', md5('website.com') );`

COOKIEHASH is essential

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.