3

I have two wordpress installs each on their own sub domain.

sub1.domain.com and sub2.domain.com

I want to share the login information between sub1 and sub2. I already have configured them to use the same MySQL database, and they use the same database table.

I am able to log in on both websites with the same credentials.

Sub2's wp-config.php file has the following code:

define('CUSTOM_USER_TABLE', 'wp_c_users');

define('CUSTOM_USERMETA_TABLE', 'wp_c_usermeta');

This all works great. My problem, is that the cookies are not being shared between the sites. Instead of sharing the cookies both sites just delete the others and create a new cookie.

I added the following code to both sub1 and sub2's wp-config.php:

define('COOKIEPATH','domain.com/'); // Replace with your initial domain name
define('SITECOOKIEPATH','domain.com/'); // Replace with your initial domain name
define( 'COOKIEHASH',    md5( 'Y@^ET#UF!RG7#KQXP04^WF' ) );
define('COOKIE_DOMAIN', 'domain.com');

When a user logs in to sub1, the cookie is created just fine, then when I go to sub2.domain.com, I am not also logged in on this site.

When I then try to log in to sub2.domain.com, it deletes sub1's cookies and overwrites them.

How can I get these two wordpress installations to use the same cookie instead of overwriting eachothers??

Any help much appreciated!

  • I even setup an a new subdomain called Test and tried to share cookies between the main domain and the new sub domain but it didn't work. I am guessing this method no longer works with WordPress. – Paul Hill Jan 20 '17 at 0:00
1

Today, I've posted a working solution for exactly the same problem. You can see it here: How to share WordPress session and cookies between domain and subdomain?. I use this method on several of my own websites.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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