Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have my cookie domain set for .a.com. All the sub domains work great with a single sign on.
If however, I create other top level domains such as b.com or c.com, I can't even sign in to them separately.
I don't need to have the sessions traverse the top level domains. I am just confused as to how to enable other sessions.
Thanks
Philbert
Comments
Comment #1
agentrickardDo not hardcode $cookie_domain in settings.php.
Comment #2
agentrickardAlternately, you can wrap that in some PHP logic.
e.g.
If you leave $cookie_domain blank, Drupal will auto-assign a cookie to the proper domain.
Comment #3
MrPhilbert CreditAttribution: MrPhilbert commentedI hard coded the cookie domain to enable persistent sign on across sub domains. It looks like the code above will do that but not disable other domains.
Thank you again sir. I'll give it a whirl.
Philbert
Comment #4
MrPhilbert CreditAttribution: MrPhilbert commentedJust used your statement and it works. Since it's in the settings.php file, the php tags do not belong as embedding php tags in a php document gives a parse error.
if (isset($_SERVER['HTTP_HOST']) && substr_count($_SERVER['HTTP_HOST'], 'parentdomain.com') > 0) {
$cookie_domain = '.parentdomain.com';
}
worked.
By the way,
You are the most responsive person on Drupal.org!
Thanks again
Philbert
Comment #5
agentrickardThe php tags are just there for formatting on drupal.org.
You can repay the favor by adding this tip to the online documentation. Perhaps a note under $cookie_domain here: http://drupal.org/node/1096962 (or a link there to a new page with these advanced instructions.