This question already has an answer here:

We have 2 WordPress sites in 2 different sub-domains like test1.abc.com and test2.abc.com . Both sites have wp-require plugin activated and only logged-in users can see the site. We want to make a system where if a user logged into one site, he should be auto-login into the other one.

What I did:

After some searching I know I need to use one database for both sites. So I have done these steps:

  1. I have download the whole database of test2.abc.com site and change all prefix wp_ to wpmo_, replace it in whole database and upload it into first site's database.
  2. I added these 2 lines in wp-config.php of the second site, to define that second site should use first site's user table not its own one.

     define('CUSTOM_USERMETA_TABLE', 'wp_usermeta');
     define('CUSTOM_USER_TABLE', 'wp_users');
  3. Now, the second site is using the first site's users and I am able to login to the second site by the user details of first site.

  4. The next problem is cookies, so I added these lines in wp-config of both sites.

    define('COOKIE_DOMAIN', '.abc.com');
    define('COOKIEPATH', '/');
  5. Now I logged in into test1.abc.com and when I go to test2.abc.com , it asks me to login. That means cookies are not passing from the first site to the second one.

Both subdomains are on same server and sharing same database user table.

I know it is a cookie issue and I have gone through many articles on that, but they all talk about sharing cookies between a domain and its subdomains. Here I am having 2 subdomains.

marked as duplicate by fuxia Jan 27 '17 at 5:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Are you actually using WordPress Multisite, or have you got two separate WordPress installations? (It sounds like the latter.) – Pat J Jun 17 '15 at 14:31
  • yes, it is the later one. – Gaurav Jun 17 '15 at 14:44

Hi Multisite User Management plugin will help you


  • multisite is not an option for me, thanks for help. – Gaurav Jun 17 '15 at 14:45

See my answer on this exact problem. Long story short, you also need to define COOKIEHASH, otherwise the login cookie names will be different for each site:

define( 'COOKIEHASH', 'randomhash' );

Make sure to change randomhash to a real hash, you can grab one here.

  • Hi @TheDeadMedic , this one really helpful. but now when i go to second website, it says "You do not have sufficient permissions to access this page." – Gaurav Jun 17 '15 at 14:46
  • You're using the same database for both installs right? Each will have a different table prefix - you need to find {table_prefix_site_1}_capabilities in the user meta table and clone it, changing the key to {table_prefix_site_2}_capabilities – TheDeadMedic Jun 17 '15 at 15:03
  • now when i try it on my actual websites, its not working :( . now i login to first site and than go to second, its not auto login. however , when i come back to first site and refresh, it also get logged out automatically. i have added this code in both wp-config.php file. define('CUSTOM_USER_TABLE', 'wp_users'); define('CUSTOM_USERMETA_TABLE', 'wp_usermeta'); define('COOKIEHASH', 'aee53c017c29dc0d3ae37253fc8cbfd8'); define('COOKIE_DOMAIN', '.techstriker.com'); define('COOKIEPATH', '/'); – Gaurav Jun 19 '15 at 7:39

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