title: yii2 login user manually with getting user and password from ajax
body: <p>i send mobile number as username and active_code as password from view file(<a href="/questions/tagged/ajax" class="post-tag" title="show questions tagged &#39;ajax&#39;" rel="tag">ajax</a>) to action with <a href="/questions/tagged/jquery" class="post-tag" title="show questions tagged &#39;jquery&#39;" rel="tag">jquery</a>and i want login user with this data.</p>
  
  <p>This code is my action:</p>
  
  <pre><code>//if entered information is correct then do:
  $identity = \common\models\User::findOne(["username"=&gt;$mobile]);
  if(Yii::$app-&gt;user-&gt;login($identity))
     return 100;
  else
     return 500;
  </code></pre>
  
  <p>It is worked(<code>return 100</code>) but after page refreshed, it seems user not logged in!
  Is there any way to do this?</p>