title: Username changes with every new registration in YII framework
body: <p>I am working on an application built with YII framework. Once the admin  logins, the app redirects to dashboard where in the top right corner we can find the user name as SUPERADMIN. However, when i created a new registration form and adds a user, and on refreshing the dashboard page, instead of superadmin, i am seeing the newly registered user name. how to resolve this? below is the code.</p>
  
  <pre><code>dashboard url : http://localhost/myAPP/frontend/web/dashboard
  Registration form URL: http://localhost/myApp/frontend/web/site/signup
  </code></pre>
  
  <p>in dashboard using <code>&lt;?php echo ucfirst(Yii::$app-&gt;user-&gt;identity-&gt;firstname); ?&gt;</code>
  prints the username as SUPERADMIN. however the same code after new user registration showing the new user name. Please help.</p>
  
  <p>Here is my signup code. </p>
  
  <pre><code>public function actionSignup()
      {
          $session = Yii::$app-&gt;session;  
          $labId = $session-&gt;get('labId');               
          if ($labId) {
              if ($session-&gt;get('role') == 'super admin') {
                  $model = new SignupForm();
                  $success = NULL;
                  if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
                      if ($user = $model-&gt;signup()) {
                          if (Yii::$app-&gt;getUser()-&gt;login($user)) {
                              $success = "User registered successfully.";
                              $model = new SignupForm();
                              return $this-&gt;render('signup', [
                                  'model' =&gt; $model, 'success' =&gt; $success,
                              ]);
                          }
                      }
                  }
  
                  return $this-&gt;render('signup', [
                      'model' =&gt; $model,'success' =&gt; $success,
                  ]);
              } else {                
                  return $this-&gt;goBack('../dashboard');
              }                       
          } else {          
              return $this-&gt;goBack('site/login');
          }          
      }
  </code></pre>