title: Session values get overwritten when multiple users access in YII
body: <p>I am working on 'Forgot Password' functionality using YII framework. The flow is as such --></p>
  
  <p>At the Login Page , a Link 'Forgot Password' is provided. On clicking it, a new view is rendered where the user needs to put his EMail Address . A mail is delivered to the Mail ID and a link is provided  in that mail on clicking of which the User will be taken to 'RESET Password' PAge where he can SET a new password.</p>
  
  <p>I am working with Sessions for fulfilling this scenario.The issue is that Session is being overwritten and only the latest entered EMAIL Address(User) can RESET the password (when tried  by entering Multiple EMAIL ID's one after other).</p>
  
  <p>1)Firstly I have started the session after the 'Submit Button' is clicked.A random string is kept in the session and send to the EMAIL . When User Clicks on the reset link , the RESET page is opened and if the string matches with the Session String then the Password can be reset . </p>
  
  <p>All these works fine if  worked with only one EMAil . if i enter two Email ID's .. I get the mail on Both with reset link generated ,,,, but when  I click on the reset link of first Mail ID ,,, i get Error messsage where as when i click the reset link received in second MAil Address ,, then it works . </p>
  
  <pre><code>public function actionForgotPassword()
      {
          $model = new ForgotPasswordForm;
          $userModel = new UserDetails;
  
          if(isset($_POST['ForgotPasswordForm']))
          {
              $model-&gt;attributes = $_POST['ForgotPasswordForm'];
  
              // validate user input and redirect to the previous page if valid
              if($model-&gt;validate())
              {
                 $getMail = $_POST['ForgotPasswordForm']['email'];
                 $user = UserDetails::model()-&gt;findByAttributes(array(
                              'email' =&gt; $getMail
                 ));
  
                  if($user)
                  {
                      session_start();
  
                      $sessionString = $model-&gt; genRandomSaltString();
                      Yii::app()-&gt;session['identityString'] = $sessionString;
                     ///Below is the MAIL function
                  }
  }}}
  </code></pre>
  
  <p>The Code on RESET PAge is </p>
  
  <pre><code>public function actionNewPassword()
      {
          session_start();
          $model = new ChangePasswordForm;
          $userModel = new UserDetails;
          $email = Yii::app()-&gt;request-&gt;getParam('tag');
          $getSessionKey = Yii::app()-&gt;request-&gt;getParam('key');
          //print_r($_SESSION);die;
          $catchSessionValue = Yii::app()-&gt;session['identityString'];
          if(!empty($_SESSION) &amp;&amp; !empty($catchSessionValue))
          {
              if($catchSessionValue == $getSessionKey &amp;&amp; $email !== null)
              {
  
                      $user_arr = UserDetails::model()-&gt;findByAttributes(array('email' =&gt; $email));
                      $user_name = $user_arr['username'];
                      $user_id = $user_arr['id'];
  
                      Yii::app()-&gt;user-&gt;setFlash('info', "Enter your New Password here.");
                      if(isset($_POST['ChangePasswordForm']))
                      {
                          $this-&gt;render('changepassword',array('change_pw_form'=&gt;$model,'user'=&gt;$user_arr));
                      }
                      else{
                          $this-&gt;render('changepassword',array('change_pw_form'=&gt;$model,'user'=&gt;$user_arr));
                      }
  
              }
              else
              {
                  Yii::app()-&gt;user-&gt;setFlash('error', "Something went Wrong. Try Again!");
                  $this-&gt;render('changepassword');
                  //$this-&gt;redirect(Yii::app()-&gt;createUrl('site/login'));
              }
  
          }
          else
          {
               $user_arr = UserDetails::model()-&gt;findByAttributes(array('email' =&gt; $email));
              Yii::app()-&gt;user-&gt;setFlash('error', "Sorry ! The link has been expired. Please try again.");
              $this-&gt;render('changepassword',array('change_pw_form'=&gt;$model,'user'=&gt;$user_arr));
           //   $this-&gt;redirect(Yii::app()-&gt;createUrl('site/login'));
          }
          }
  </code></pre>