title: Change language in Yii2
body: <p>I want to change language using dropdown for English and Norwegian. 
  Code is working fine but issue is it is working for only one time, whenever I refresh page language is change to English.</p>
  
  <p><strong>view page.</strong></p>
  
  <pre><code>&lt;select class="form-control user_language"&gt;
      &lt;option value="en"&gt;English&lt;/option&gt;
      &lt;option value="nl"&gt;Norwegian&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><strong>JS Code.</strong></p>
  
  <pre><code>&lt;script&gt;
     $(".user_language").change(function(){
       language=this.value;
       $.ajax({
          url:'&lt;?=Yii::$app-&gt;request-&gt;baseUrl?&gt;/site/changelanguage',
          type:"GET",
          data:{language:language},
          success:function(result){
            console.log(result);
            location.reload();
          },
      });
     });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function actionChangelanguage()
  {
    if(isset($_REQUEST['language']) &amp;&amp; $_REQUEST['language']!=null)
    {
      Yii::$app-&gt;language='nl';
      echo Yii::$app-&gt;language;
      die;
    }
  }
  </code></pre>
  
  <p>I have checked that it working for one time whenever I refresh page, language is change to English.</p>
  
  <p>If I put  <code>Yii::$app-&gt;language='nl';</code> in every page it is working but I don't want to put this code in every page.</p>