A client has two domain names, a .ca and a .com, that both point to the same D7 site (same codebase, same database, no custom sites folder for either of them, so it's not a multisites situation; the Apache document root path is simply the same for both sites). Everything works fine except that nobody can log in to the .com version. There is no "unrecognized username or password" or other error generated, it just doesn't log them in. (Incorrect passwords do generate the error message.) Checking the log messages, I see that it opened and then immediately closed a session.

Changing cookie settings is not a viable approach here, because it's different top-level domains, not different subdomains.

One possible solution is to redirect one domain to the other instead of running them "in parallel" (I'm aware of the methods, pros and cons of this approach), but I'm interested in why this is and what else can be done about it.

  • 1
    Is it redirecting you to the .ca domain after login? Drupal generates a session on login, so logging in at the .com wouldn't give you access to it via the .ca Try manually pasting in domain.com/admin after you've logged in at the .com – user5482 Sep 18 '15 at 19:04

I had this issue before. It is related to the cookie setting, try doing this:

if (isset($_SERVER['HTTP_HOST']) && substr_count($_SERVER['HTTP_HOST'], 'parentdomain.com') > 0) {
$cookie_domain = '.parentdomain.com';
| improve this answer | |
  • Nice answer, I ran into this issue myself just 2 weeks ago - I solved it by setting respective cookie_domain values in /sites/<domainName/settings.php. – stefgosselin Sep 20 '15 at 1:33

In this case, it seems that it's a conflict with the phpbbforum module. Probably some setting in there that's got it's cookie domain set to the .ca instead of figuring it out dynamically, similar to what @Drupalfan said. They're not actually using the forums at the moment anyway, so I've simply disabled that and logins now work through both domains without any other Drupal code or setting changes. I'll investigate it more closely (and try to remember to report back with a more complete solution) if and when they want to start using the forums.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.