title: Yii2 Role swiching after login
body: <p>A user has 3 roles. </p>
  
  <ol>
  <li>RoleOne</li>
  <li>RoleTwo</li>
  <li>RoleThree</li>
  </ol>
  
  <p>After Login I want to activate one of his roles active mode and rest of roles inactive mode. Does Yii2 have any role switching technique?
  Or we have to make our own logic.</p>
  
  <p>Here is how I am trying to achieve this...</p>
  
  <pre><code>$auth = new DbManager;
  $auth-&gt;init();
  
  //here I will get all roles of user              
  $roles = $auth-&gt;getRolesByUser(Yii::$app-&gt;user-&gt;identity-&gt;id);
  </code></pre>
  
  <p>Now after this how can set active role from <code>$roles</code> variable. In between user can activate other roles also. I am here confused actually there is no yii2 functionality like switching roles any time after login.</p>