title: How to get the logged in user id
body: <p>sorry for not specifying question properly as i dont even know what should i write on there but here is my problem.</p>
  
  <p>I have 2 tables <code>users</code> and <code>organiser</code> and they both are using same desktop system for different privileges on my project and have 2 different <code>login</code> pages.</p>
  
  <p>Now the confusion is that I want to introduce another feature to list the advertisement on website and i want both of the users to post ad on website. For that sometimes i need to get the <code>id</code> and other details of the logged in user,so what should i do here to know which <code>user</code> is logged in or <code>organiser</code> is logged in?</p>
  
  <p>Should i make any changes in database? or add any extra field in the <code>advertisement</code> table which indicates which type of user has created that record??? I am using <code>yii2</code> framework if that matters.</p>
  
  <p>Here is the code of <code>frontend</code> configuration file in <code>yii2</code></p>
  
  <pre><code>return [
  'id' =&gt; 'app-frontend',
  'controllerNamespace' =&gt; 'frontend\controllers',
  'defaultRoute' =&gt; 'event/index',
  'components' =&gt; [
      'user' =&gt; [
          'identityClass' =&gt; 'common\models\User',
          'enableAutoLogin' =&gt; true,
          'identityCookie' =&gt; [
              'name' =&gt; '_frontendUser', // unique for frontend
          ],
      ],
  
  
      'session' =&gt; [
          'name' =&gt; 'PHPFRONTSESSID',
          'savePath' =&gt; sys_get_temp_dir(),
      ],
      'request' =&gt; [
          // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
          'cookieValidationKey' =&gt; 'YNdaEYHtai',
          'csrfParam' =&gt; '_frontendCSRF',
      ],
  
     ],
   ];
  </code></pre>