title: SessionStorage, get only last values
body: <p>I have PHP file with this function and code:</p>
  
  <pre><code>&lt;?php
     $valuesNight = select_sensor_data7($db, $idSensor, $date22y, $date6t);
      chart_line($valuesNight);
  
      $valuesEvening = select_sensor_data7($db, $idSensor, $date6t, $date14t);
      chart_line($valuesEvening);   
    ?&gt;
  
  &lt;?php function chart_line($values7){ ?&gt;
  &lt;div&gt;
      &lt;script type="text/javascript"&gt;
  
          var values7 = &lt;?php echo $values7 ?&gt;;
          var value7 = new Array;
          var time7 = new Array;
  
          for(var o in values7) {
              value7.push(values7[o]['dValue']);
              time7.push(values7[o]['dTimeDate']);
          }
          //alert(time7);
          // store values
          sessionStorage.setItem('myValues', JSON.stringify(value7));
          sessionStorage.setItem('myTime', JSON.stringify(time7));
      &lt;/script&gt;
  
      &lt;object type="text/html" data="chart.htm" width="100%"  height="420"&gt;&lt;/object&gt;
  &lt;/div&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>And <code>select_sensor_data7()</code></p>
  
  <pre><code>function select_sensor_data7($db, $idSensor, $dateFrom, $dateTo){
  $stmt = $db-&gt;prepare("SELECT * FROM sensorData WHERE _idSensor = :idSensor 
                          AND dTimeDate BETWEEN :dateFrom AND :dateTo ORDER BY dTimeDate");
      $stmt-&gt;execute(array(':idSensor' =&gt; $idSensor, ':dateFrom' =&gt; $dateFrom, ':dateTo' =&gt; $dateTo));
      $row2 =$stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
      $json=json_encode($row2);
  return $json;
  }
  </code></pre>
  
  <p>And in <code>chart.htm</code>:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var myTime = JSON.parse(sessionStorage.getItem('myTime'));
      var myValues = JSON.parse(sessionStorage.getItem('myValues'));
  
      alert(myTime);
  </code></pre>
  
  <p><strong>Problem:</strong>
  <code>select_sensor_data7</code> return object with values and time between dates, <code>chart_line($valuesNight)</code> and <code>chart_line($valuesEvening)</code> run function. In  function <code>chart_line($values7)</code>  <code>alert(time7)</code>shows me right values , but in <code>chart.htm</code> i get only last values <code>valuesEvening</code>.</p>
  
  <p>Where am i doing wrong?</p>