title: yii 2.0 get logged in user's Session ID
body: <p>Am new to Yii, this is the login function (path /basic/controllers/siteController.php), once the users is logged in it will render the login template.</p>
  
  <p>After a user is logged in, </p>
  
  <p>How to get the SESSION ID and store to DB. ?</p>
  
  <pre><code>public function actionLogin()
  {
      if (!Yii::$app-&gt;user-&gt;isGuest) {
          return $this-&gt;goHome();
      }
  
      $model = new LoginForm();
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;login()) {
          return $this-&gt;goBack();
      }
      return $this-&gt;render('login', [
          'model' =&gt; $model,
      ]);
  }
  </code></pre>
  
  <p>And the model code (path /models/LoginForm.php)</p>
  
  <pre><code>public function login()
  {
      if ($this-&gt;validate()) {
          return Yii::$app-&gt;user-&gt;login($this-&gt;getUser(), $this-&gt;rememberMe ? 3600*24*30 : 0);
      }
      return false;
  }
  </code></pre>