Hi Support,
Setup:
Running EE 2.5.2, MSM 2.1.3
Example domain: http://www.domain.com (note the www for purposes of below explanation).
MSM sites running in subfolders of that domain (e.g. http://www.domain.com/site2).
ALL MSM sites access same CP at http://www.domain.com/admin.php
Problem:
Today’s cookie saga started when I tried to “Login as member” by Super Admin:
Members > View All > Select a member > Member Administration > Login as member
I would follow the steps, Submit the form to be returned to the CP, yet when I returned the CP, I was still logged in as my same Super Admin. No matter that I tried, I’m unable to “switch” to being logged in as a different user.
Through various hunting, I’ve tracked down a chunk of code which, when commented out, restores the ability to “switch”:
system/expressionengine/core/EE_Config.php, starting around line 272 (all comments shown here are straight from EE_Config.php):
// Control Panel Cookie Domain
// Since the cookie domain changes based on the site chosen in the CP,
// and since one could have multiple CPs, some using admin.php with path.php,
// we have to be a bit more creative in figuring out the correct,
// usable cookie domain for the CP
if (REQ == 'CP' && $this->item('multiple_sites_enabled') == 'y')
{
$this->cp_cookie_domain = '';
if ($site_name != '')
{
$this->cp_cookie_domain = $this->config['cookie_domain'];
}
else
{
...
}
}Within the ELSE block that I’ve omitted for brevity, the code ends up calculating the CP cookie domain by piecing parts of the $_SERVER[‘HTTP_HOST’] together. Due to its calculations, it sets my cp_cookie_domain to “.domain.com”, but if you note my example domain, I’m operating specifically on a domain with ‘www’ as the prefix.
As soon as I comment out this entire chunk - from 272 to 336 - my CP returns to working perfectly. I can log in as another member, log out, back in, as well as continue to successfully switch from one MSM site to another within the CP. AND I can also log into another EE install on a parallel subdomain (e.g. http://www2.domain.com), again without problems.
I have explicitly NOT set a cookie_domain through my config.php, index.php, admin.php, or otherwise.
Could someone take a look at this and give any insight as to whether it’s “working” as it’s supposed to? And in that case, what I’m doing wrong in my setup?
Cheers,
John