Subdomain with shared database for users: subdomain not accessing primary database
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.