title: Is it possible to check if the user is logged in in php script which has embedded yii2?
body: <p>I put a custom script in main yii2 installation directory and I need to know in this script if user is logged in main yii2 app(called frontend).
  I use this code</p>
  
  <pre><code>require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
  
  $yiiConfig = require __DIR__ . '/../config/yii/web.php';
  new yii\web\Application($yiiConfig); // Do NOT call run() here
  </code></pre>
  
  <p>from:
  <a href="https://www.yiiframework.com/doc/guide/2.0/en/tutorial-yii-integration#using-yii-in-others" rel="nofollow noreferrer">https://www.yiiframework.com/doc/guide/2.0/en/tutorial-yii-integration#using-yii-in-others</a></p>
  
  <p>And use this code</p>
  
  <pre><code>Yii::$app-&gt;user-&gt;identity-&gt;id;
  </code></pre>
  
  <p>but it throws that app variable is not available. I tried other combinations but nothing worked.</p>