Subdomain with shared database for users: subdomain not accessing primary database I've successfully set up a multisite Drupal installation. I now have:

www.example.com --> main site
sub.example.com --> a secondary site

However, I want the users to be shared. I know about shared databases and prefixes, but according to the comments in the settings.php, you can also use the prefixes to access a different database. I'd like to choose that root.

So my main site goes to the primary database, the subdomain goes to the secondary database, except for the users.

This is relevant section of the settings.php of my subdomain:

$databases = array (
    'default' =&gt; 
        array (
            'default' =&gt; 
                array (
                    'database' =&gt; 'secondary_database',
                    'username' =&gt; 'username',
                    'password' =&gt; 'password',
                    'host' =&gt; 'localhost',
                    'port' =&gt; '',
                    'driver' =&gt; 'mysql',
                    'prefix' =&gt; array(
                        'default'   =&gt; '',
                        'users'     =&gt; 'primary_database.',
                        'sessions'  =&gt; 'primary_database.',
                        'role'      =&gt; 'primary_database.',
                        'authmap'   =&gt; 'primary_database.',
                        ),
                ),
        ),
);


My primary database already has many users, but when I log into my secondary site, I only see my admin user. Also, I cannot log in to my subdomain with any user of my primary database.

So my conclusion is that the subdomain is still using its own database.

Both databases are on the same server and I've given the username/password for the secondary database access to the primary database.

There are also no errors in the log.

Any suggestions on what I'm missing?
I would advise to look into the answers of this question. One solution is indeed a specific setup in settings.php, however all your sites need to make use of the same database when using that option. E.g.:

$databases['default']['default'] = array(
  'driver' =&gt; '[Your database engine]',
  'database' =&gt; '[Your database name]',
  'username' =&gt; '[Your username for the access to the database engine]',
  'password' =&gt; '[The password for the access to the database]',
  'host' =&gt; 'localhost',
  'prefix' =&gt; array(
    'default'   =&gt; 'main_',
    'users'     =&gt; 'shared_',
    'sessions'  =&gt; 'shared_',
    'role'      =&gt; 'shared_',
    'authmap'   =&gt; 'shared_',
  ),
  'collation' =&gt; 'utf8_general_ci',
);


The solution above uses the same database for all sites, but different table prefixes. So in the example above most tables will be prefixed with "main_", but the users, sessions, role and authmap tables will be prefixed with "shared_". For your additional sites, you will use a different prefix for 'default' (maybe 'site2_', 'site_3', etc.) but the same 'shared_' prefix.

(all credits to zdecibel &amp; Dalin for the example &amp; explanation above)

Another option is using the Domain Access module, which is developed for this kind of purposes.