I am using Drupal 7 to configure a new single Drupal site that uses two languages (English and French), using Locale with the "Language domain" setting enabled. This site requires both the display and the admin language to be switchable, and almost have it working! I have just one last issue.

When I visit "en.dev.example.com" I can log in everything seems to be working great; when I switch to "fr.dev.example.com" while logged in, I am no longer logged in. I can actually have two different users logged in at once, using the same browser, on each domain.

This is not desired! This Drupal site is not a multi-site, and I don't want it to behave like that. When someone logs in, I need them to stay logged in also when they switch languages. This is because many users will be totally bilingual and need to see the site content in both the languages. This is important, since the content is membership based.

I started out setting the "Path prefix language code" in my language settings which was working well; you could switch languages without problems and stay logged in while doing so. Perfect! Except…

I had to change the method of handling languages to "Language domain" because the URLs created by some modules (namely the Advanced Forum module, but I am sure it will come up in other places) were not respecting the path language prefixes, and giving many 404s. I really need to use the subdomain method!

I created two subdomains via my hosting account, one is "en.dev.example.com" and the other is "fr.dev.example.com" (both using subdomains to give each language equal significance). I changed the "Language domain" for each language, and am now able to see both language versions by using the subdomains I created, as expected.

What can I do to make sure users stay logged in when they switch language after starting their session, while using the "Language domain" option?

I cannot locate any info or forum posts for Drupal 7 on this particular issue... Do I need to make some changes to my settings.php file? I also couldn't find D7 documentation on setting this up (only for path prefixes), so it's possible that I have missed a step.

I have been at the languages settings for a few days now, and I have made real progress, but I feel totally stuck at this point, the last problem! I would absolutely love some advice at this point.

2 Answers 2


Try adding this to settings.php

$cookie_domain = '.dev.example.com';
  • Thank you for taking the time to answer my question!, I tried this solution, unfortunately it does not work Commented Jan 21, 2014 at 14:46
  • Try just $cookie_domain = '.example.com';, that might do it...
    – Clive
    Commented Jan 21, 2014 at 14:55
  • 1
    @Abdelouahed You may also need to log out everywhere, and potentially clear the {sessions} table so you get a new cookie.
    – mpdonadio
    Commented Jan 21, 2014 at 15:17

Clive's solution is normally all you need to do. I had a similar problem on a multilingual site, and this settings.php change resolved this.

Besides what MPD suggested, you can simply wait for the sessions table to clear (generally is set to about 6 hours by default), and also clear the caches and history from your Web browser.

Even if the fix works, if your browser is relying on cached data, you may not see the change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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