title: How to pass variable from Module to Controller in Yii2?
body: <p>I am building restful stateless API using Yii2... So far so good. Now I failed at rookie problem.</p>
  
  <p>I have decided to make API application (preferred by Yii) and make API as a module. So my structure is:</p>
  
  <pre><code>- modules
  -- v1
  --- components
  --- controllers
  --- models 
  </code></pre>
  
  <p>Inside v1 folder of course there is Module.php. In here I do authentication like: </p>
  
  <pre><code>$behaviors['authenticator'] = [
              'class' =&gt; HttpBasicAuth::className(),
              'auth' =&gt; function($username, $password) {
              ... get user's data from DB ...
              [HERE]
              }
      ];
  </code></pre>
  
  <p>and at point <code>[HERE]</code> I sotre user's ID in public variable. </p>
  
  <p>So far so good...</p>
  
  <p>So when I for example call <code>v1/abc/index</code> abc controller loads in inside that controller I would like to access user's ID stored at point <code>[HERE]</code>. Any idea?</p>