Hi there,
On this page (http://drupal.org/node/49605) there is some explanation on setting up a single codebase, shared database, shared sign-on installation. Could you please add the following at the bottom of that page, before the "Some things which can be improved:" part?
Thank you,
Sander Toonen
P.s. My English sucks, so please edit when i'm talking garbage
Sharing sessions among subdomains:
In the settings.php file of each individual site you will find the following code:
$domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
This codes ensures that sessions will only be valid at the subdomains when you logged in at example.com, www.example.com or that specific subdomain. When you log in at sub.example.com, your will still be logged out when visiting sub2.example.com. If you want your sessions to be valid throughout the entire domain regardless where you logged in, uncomment that line and add the following code underneath:
$domain_parts = array_reverse(explode(".", $_SERVER['HTTP_HOST']));
$domain = '.' . $domain_parts[1] . '.' . $domain_parts[0];
This code will set your cookie domain to .example.com, even if you log in at sub.example.com.
Comments
Comment #1
pnm commentedHere's some alternate code:
$domain = '.' . implode('.', array_slice(explode('.', $_SERVER['HTTP_HOST']), -2, 2));which generalizes to 3rd and 4th level domain names like example.co.uk:
Comment #2
betz commentedChanged the component to reflect the new component categorization. See http://drupal.org/node/301443
Comment #3
betz commentedComment #4
heather commentedThe link to the handbook page is "Page not Found"
link rot: http://drupal.org/node/49605
I cannot locate a similar page.
I am marking this outdated. Can someone confirm this?
Comment #5
johnnocThe poster wanted to add his code before the "Some things which can be improved" part. Since the given link results to "Page Not Found", I tried to search google for the exact phrase (http://www.google.com/search?q=%22Some+things+which+can+be+improved%22+s...). The Google result is only to this issue. Well...we cannot find the page so I'm marking this "won't fix". Besides, this is a 2 year old issue that is probably for Drupal 4.7 or earlier.