title: How to add more user identity session attributes in Yii2?
body: <p>In Yii2 you can access the identity interface for the current user by using the identityInterface object from within the \yii\web\User class with something like this </p>
  
  <pre><code> \Yii::$app-&gt;user-&gt;identity-&gt;id;
  </code></pre>
  
  <p><strong>Is there a way to get and set additional parameters (without extending the identity class)?</strong> </p>
  
  <p>Basically a equivalent of Yii 1.x <code>getState()</code>, and <code>setState()</code> methods in <code>CWebUser</code> to store and retrieve session information like this </p>
  
  <pre><code>Yii::app()-&gt;user-&gt;setState("some_attribute",$value);
  Yii::app()-&gt;user-&gt;getState('some_attribute',$defaultValue);
  </code></pre>