title: Automagically Log into Multiple Domains in Yii2
body: <p>I have a site with a root domain and several sub domains, each a separate yii2 module. At the moment I have to log into each sub domain individually. I want to be able to log into the root directory and then be automatically logged into each of the sub domains. There are a few pages here and there on the web about achieving this but nothing that works. </p>
  
  <p>at the moment I have the same setup in both main.php config files (i.e. the root domain and one of the sub domains that I am testing with)</p>
  
  <pre><code>'components' =&gt; [
      'request' =&gt; [
          'enableCookieValidation' =&gt; true,
          'enableCsrfValidation' =&gt; true,
          'cookieValidationKey' =&gt; 'XXXXXXX',
      ],
      'user' =&gt; [
          'class' =&gt; 'yii\web\User',
          'identityClass' =&gt; 'common\models\User',
          'enableAutoLogin' =&gt; true,
          'identityCookie' =&gt; [
              'name' =&gt; '_myapp',
              'httpOnly' =&gt; true,
              'path' =&gt; '/',
          ]
      ],
      'session' =&gt; [
          'name' =&gt; 'MYAPPSESSID',
          'cookieParams' =&gt; [
              'path' =&gt; '/',
          ],
      ],
  </code></pre>
  
  <p>When inspecting my cookies in Chrome after logging in with setup I see two cookies, one for the main site and one for the sub domain, they are both called MYAPPSESSID, and both containing different 'keys' that presumably hook up to the user info set on the PHP session. I get that these two cookies should be one cookie so that both domains hook up to the session user object - but I;ve tried all the different settings I can think of and can't get this to work. </p>