I can't find information how to make a single login for users on domain and it subdomains. I know it is possible for a domain and IT SUBdomains (but not in another domain - some internet rule).

At first I thought that DA alias is a different patch for domain, so I have created another "domains" for my subdomains.

domain1.com
subdomain1-of-domain1.com (another domain not aliased)
subdomain2-of-domain1.com (another domain not aliased)

Is there a easy way to change domains to aliases ? It is even needed for shared login ? Do I need to set my cookies to domain1.com for shared login ?

If somebody could explain this process I would be glad. Thx.

Comments

croryx’s picture

Shared logins just require that you set the cookie domain correctly. See the cookie domain section of the documentation for configuring settings.php (http://drupal.org/node/1096962).

kerios83’s picture

@croryx, thx for this info ! I have set up this correctly (for one domain - $cookie_domain = '.domain1.com';) - I did not have to change domains to aliases. But I have also few other domains I want to use. So if all of those domains will point to one cookie, nothing wrong is gona happen ?

domain1.com
subdomain1-of-domain1.com (another domain not aliased)
subdomain2-of-domain1.com (another domain not aliased)

domain2.com
subdomain1-of-domain2.com (another domain not aliased)
subdomain2-of-domain2.com (another domain not aliased)

domain3.com
subdomain1-of-domain3.com (another domain not aliased)
subdomain2-of-domain3.com (another domain not aliased)

How to set up this configuration ? So domain1.com user will automaticaly log in to subdomain1-of-domain1.com and domain2.com user will automaticaly log subdomain1-of-domain2.com. I did't test it with one cookie cause I'm biuilding domain2 and it's subdomain atm :) Will this work for me. BTW thx for this GREAT module !

croryx’s picture

The great module is all due to @agentrickard, I just help around the queue with the simple stuff when I can, and since your current question isn't simple enough for me to know the answer to I'll have to leave this for him.

agentrickard’s picture

Issue tags: +handbook

You would need to wrap $cookie_domain in some logic similar to:

if (isset($_SERVER['HTTP_REQUEST'])) {
  if (substr_count($_SERVER['HTTP_REQUEST'], 'domain1.com') > 0) {
    $cookie_domain = '.domain1.com';
  }
  elseif (substr_count($_SERVER['HTTP_REQUEST'], 'domain2.com') > 0) {
    $cookie_domain = '.domain2.com';
  }
  // And so on. You might also be able to do regex matching.
}

This all goes in settings.php, before the DA include.

agentrickard’s picture

Status: Needs review » Active
kerios83’s picture

Thanks for answers guys. I will test it as soon as I finish build sites for rest of the domains.

Punchy’s picture

Hello guys !
I hope this issue match up with my problem !

on my localhost I created 2 domains with (wonderfull) Domain Access module :
domain1.dev
domain2.dev
I'd like when the users log in one of this 2 domains they're automatically log in the other one, is it possible ?

I tried #4, it doesn't work.
Then I tried this :
http://drupal.org/node/1348784
It seems corresponding what I want but it doesn't work, maybe I did it wrong ?

I put this in settings.php before the Domain Access include :

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

Please can you tell me what I'm doing wrong ?
Thanks for help and sorry for my bad english T__T

agentrickard’s picture

You can't do this because browser security won't let you store the same login cookie for two domains that don't share a top level.

e.g. if you had 'example.com' and 'one.example.com', you can share '.example.com'.

In your setup, the Drupal login cookie would get reset every time a user switched domains.

See https://drupal.org/node/1096944 and INSTALL.txt.

agentrickard’s picture

Status: Active » Closed (works as designed)