Title: Shared login between subdirectory install
Last modified: August 30, 2016

---

# Shared login between subdirectory install

 *  [TrevorJones](https://wordpress.org/support/users/trevorjones/)
 * (@trevorjones)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/shared-login-between-subdirectory-install/)
 * I’ve recently taken over a project including a WP 4.2.5 install in the root folder
   and a subdirectory install for a different language. Before now both installs
   have been using separate database tables (wp1_, wp2_).
 * I’ve been searching for hours and found a lot of info on cookies, my wp-config
   settings are:
 * **Main site**
 *     ```
       define('COOKIEPATH', '/');
       define('SITECOOKIEPATH','/');
       define('COOKIEHASH', md5('www.site.co.uk'));
       ```
   
 * **Sub site**
 *     ```
       define('CUSTOM_USER_TABLE', 'site_wp1.wp1_users');
       define('CUSTOM_USER_META_TABLE', 'site_wp1.wp1_usermeta');
   
       define('COOKIEPATH','site.co.uk/');
       define('SITECOOKIEPATH','site.co.uk/');
       define('COOKIEHASH', md5('www.site.co.uk'));
       ```
   
 * I had the subsite redirecting to the successful login page but the user doesn’t
   stay logged in, access is restricted and going back to the login page shows login
   instead of logout. Still an issue with cookies?
 * **EDIT**
    Strangely, logging in on the main site will work fine, however navigating
   to the subsite will stay logged in and access is like normal except using the
   logout button navigates to the logged out page yet keeps the user logged in…
 * I can’t access the subsite/wp-admin with these settings, attempting to login 
   just refreshed the page and stays on 2 attempts left, acting as if login worked,
   but wasn’t registered…
 * All the same plugins are used on both installations.
 * Anyone know of a solution?
    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Axel13](https://wordpress.org/support/users/axel13/)
 * (@axel13)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/shared-login-between-subdirectory-install/#post-6678192)
 * I’m not sure what you are trying to achieve, or what the problem is.
    Do you 
   want members to be logged in on both sites automatically? And what do you consider
   the successful login page? Is it on the subsite?
 * For the record you are posting in the [multisite](http://codex.wordpress.org/Create_A_Network)
   forum, yet multisite doesn’t mean multiple sites with multiple installs, multisite
   is one install with multiple sites.
 * If you want members to be logged in on both sites then multisite + [Join My Multisite](https://wordpress.org/plugins/join-my-multisite/)
   could be a solution. Yet if you want your site to be multilingual you do not 
   really need multiple sites for this, it could be easier with a plugin like [Polylang](https://wordpress.org/plugins/polylang/).
 * If you have many pages/posts it could be a lot of work to change that though.
 * Either way, you can [import](https://wordpress.org/plugins/wordpress-importer/)
   the content from one site to the other. When you import to a new site make sure
   to copy all settings, the theme and plugins first (you may need to do so manually).
 * And if you choose multisite, a plugin like [Multisite Language Switcher](https://wordpress.org/plugins/multisite-language-switcher/)
   or [Zanto](https://wordpress.org/plugins/zanto/) could be helpful. I did not 
   try these though, so I can’t recommend.
 * GL with it!
 *  Thread Starter [TrevorJones](https://wordpress.org/support/users/trevorjones/)
 * (@trevorjones)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/shared-login-between-subdirectory-install/#post-6678249)
 * Very new to WP, I kind of understood multisite but wasn’t sure where to post 
   about this (kind of related).
 * I would have chosen the multisite approach but I kind of had this lumped on me
   and it’s too far down the line to go back (course website with all courses/quizzes
   already complete in both languages…) I’ve also looked into Polylang but again,
   too much work to go back…
 * Now the site is in it’s final stages I’ve just been implementing the course purchase
   which involves the customer creating an account which is activated after they
   complete a payment through WooCommerce plugin. The main issue is that the sites
   have been set up to use separate user/usermeta tables in different databases…
   So purchasing a site licence in one language doesn’t create an account in the
   other sites database. I need both main EN site and the subdirectory site to use
   the same user tables.
    The database looks like this: **site_wp1** >wp1_users 
   >wp1_usermeta
 * **site_wp2**
    >wp2_users >wp2_usermeta
 * I think targeting site_wp1.wp1_users from the subdirectory site is causing the
   problem as the query on login/out seems to be appending site_wp2. before the 
   query ending up with “site_wp2.site_wp1.wp1_users”
 *  Thread Starter [TrevorJones](https://wordpress.org/support/users/trevorjones/)
 * (@trevorjones)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/shared-login-between-subdirectory-install/#post-6678263)
 * I suppose could it be a solution to just copy all tables from the site_wp2 database
   into the wp1 database, then setting both wp-config files to use the wp1 db but
   different table prefixes…
    Probably how I’m now guessing it’s supposed to be 
   set up?
 * **EDIT**
 * Well, I just tried that and problem solved!
    Looks like no way to access another
   databases user/meta tables? Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shared login between subdirectory install’ is closed to new replies.

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 3 replies
 * 2 participants
 * Last reply from: [TrevorJones](https://wordpress.org/support/users/trevorjones/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/shared-login-between-subdirectory-install/#post-6678263)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
