[documentation] [Documentation feature] Information on session sharing between subdomains

maxonic drupal-docs at drupal.org
Thu Jan 18 23:12:55 UTC 2007


Issue status update for 
http://drupal.org/node/110645
Post a follow up: 
http://drupal.org/project/comments/add/110645

 Project:      Documentation
 Version:      <none>
 Component:    Installation
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  maxonic
 Updated by:   maxonic
 Status:       active

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.




maxonic



More information about the documentation mailing list