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

agentrickard’s picture

Do not hardcode $cookie_domain in settings.php.

agentrickard’s picture

Alternately, you can wrap that in some PHP logic.

e.g.

if (isset($_SERVER['HTTP_HOST']) && substr_count($_SERVER['HTTP_HOST'], 'example.com') > 0) {
  $cookie_domain = '.example.com';
}

If you leave $cookie_domain blank, Drupal will auto-assign a cookie to the proper domain.

MrPhilbert’s picture

I 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

MrPhilbert’s picture

Just 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

agentrickard’s picture

Status: Active » Closed (works as designed)

The 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.