1

I have a unique scenario in that I'd like to log into a single EE site but with a wildcard subdomain.

for example:

dev.example.com
staging.example.com
fishfood.example.com
anything.example.com
*.example.com

I'd like to be able to log into any one of these sites and stay logged into them all.

The examples I've seen involve knowing the number of domains for which to set the cookies, but in my case I can't anticipate every possible subdomain.

Any suggestions?

0

Here was my final solution. Within my config file, take apart the url with PHP and create a custom cookie_domain config.

The only downside is that in order for cookies to work properly across all subdomains I have to serve the site from www.example.com and not from example.com

$host = $_SERVER['HTTP_HOST'];
$host_array = explode('.', $host);
$subdomain = array_shift($host_array);
$extension = array_pop($host_array);
$domain = array_shift($host_array);

$env_config['allow_multi_logins'] = "y";
$env_config['cookie_domain'] = "." . $domain . "." . $extension;
$env_config['cookie_prefix'] = "";
| improve this answer | |
  • Did you try setting it to simply ".example.com"? I believe that's the supported method. Would also work with the non-www case. – AllInOne Jan 20 '16 at 18:17
  • this essentially does set it .example.com, the only reason for taking apart the url in php is so I can easily use this in a multi-environment config, such as dev and production where the extension or top level domain might change. regarding the no www, in my testing it did not work with without www (I am on EE 2.9 in this case, maybe it's better in EE 3 or perhaps I missed something) – mjr Jan 20 '16 at 21:58

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.