Hello,
I have a multi-site installation with shared source and indiviual databases for 20+ different sites.
Setup environment is Windows 2003 Server, Apache 2.2, PHP 5.1.6, MySQL 5, etc...
Drupal 4.7.3 installed at C:\drupal folder.
File structure is;
C:\Drupal
C:\Drupal\sites\8080.sub.domain.com.sitename1
C:\Drupal\sites\8080.sub.domain.com.sitename2
C:\Drupal\sites\8080.sub.domain.com.sitename3
...
Each site folder has a (almost identical) "settings.php" and a "files" folder. (I want to keep each sites' files seperate.)
I created standard users for each site (same login name and password).
All the sites use the same source, different databases, some common settings from settings.php
The problem is, since each site has its own database, why once I logged in to one of them I can not login to another one.
Somehow sessions/cookies are shared. Logged in user kicks out other site's logged in user.
Of course this happens when you open the sites in same brand browser windows.
What's causing this? Any idea?
p.s. I don't use clean URLs.
Here's the sample code for settings.php:
<?php
$db_url = 'mysql://username:password@localhost/databasename'; //always lowercase!
$db_prefix = 'prefix_';
$base_url = 'http://sub.domain.com:8080/CLIENTNAME'; // NO trailing slash!
ini_set('arg_separator.output', '&');
ini_set('magic_quotes_runtime', 0);
ini_set('magic_quotes_sybase', 0);
ini_set('session.cache_expire', 200000);
ini_set('session.cache_limiter', 'none');
ini_set('session.cookie_lifetime', 2000000);
ini_set('session.gc_maxlifetime', 200000);
ini_set('session.save_handler', 'user');
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
$conf = array(
'site_name' => 'Staging site for CLIENTNAME',
'theme_default' => 'bluemarine',
'anonymous' => 'Visitor',
'file_directory_path' => str_replace(dirname($_SERVER ['DOCUMENT_ROOT']).'/','',dirname(__FILE__)).'/files',
'file_directory_temp', 'C:\\PHP\\uploadtemp',
'file_downloads', '2',
'user_register', '0',
'error_level', '1',
'configurable_timezones', '0',
'date_default_timezone', '-28800',
'date_first_day', '1',
'date_format_long', 'l, F j, Y - g:ia',
'date_format_medium', 'F j, Y - g:ia',
'date_format_short', 'M j Y - g:ia',
'site_mail', 'admin@domain.com',
'site_slogan', '',
'site_mission', ''
);httpd.conf
# filename: drupal.conf
# Development - Drupal sites
# - please add sites in alphabetic order
# - use lowercase only
# ----------------------------------------------
Alias /sitename1 "C:/Drupal/"
Alias /sitename2 "C:/Drupal/"
...
Alias /sitename20 "C:/Drupal/"
<Directory "D:/Drupal/">
AllowOverride All
Options +Indexes
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Comments
Yes, it is a cookie issue.
Yes, it is a cookie issue. Since all of these sites exist on the same domain, same subdomain even, drupal looks at the cookie, and compares it against its session table. The first time it will be fine since it will match or will write a new line.
But when you proceed to a new sub site, the same cookie is checked again (but this time against a different session table), not finding a match, it throws you back into the login mode.
For your setup up to work, I believe you have to another ini_set line that makes each site save the cookie in a different folder (though I have not tested this).
Skejo.com, Where Your Knowledge is Rewarded.
----------
Drupal Blog
Dog Parks via Drupal
session.cookie_path
Thanks a lot everybody for your help. But the solution came from Gman.
I added the line below to each settings.php file with each site's path info. I just had a quick test, looks like it works just fine. I let you know if I may need to update anything.
ini_set('session.cookie_path', '/CLIENTNAME/');I'm almost sure path information must begin with a slash, but not sure about the trailing slash. I assume we should use it.
osman
I'm not certain it will
I'm not certain it will solve your problem, but have you looked into the single signon module? http://drupal.org/project/singlesignon
--
Abtech Creative: Beautiful Design Powered by Beautiful Development
the above only works with a
the above only works with a shared db according to the docs. The user has 20 seperate dbs.