title: Storing array in sessions
body: <p>I am trying to store some data as an array in the session but the function does not seem to be working.it does not throw any error but every time i add data to it, it just overwrites the previous data. I am using yii and here is the action</p>
  
  <pre><code>public function actionStoreProducts($name)
          {
              $name=trim(strip_tags($name));
              if(!empty($name))
              {
                  if(!isset(Yii::app()-&gt;session['_products']))
                  {
                      Yii::app()-&gt;session['_products']=array($name);  
                      echo 'added';
              }
              else
              {
  
                  $myProducts = Yii::app()-&gt;session['_products'];
                  $myProducts[] = $name;
                  Yii::app()-&gt;session['products'] = $myProducts;
                  echo 'added';
  
              }
  
          }
  </code></pre>
  
  <p>Can anyone suggest me how can i achieve the desired result?</p>