title: PHP: $_SESSION - What are the pros and cons of storing temporarily used data in the $_SESSION variable
body: <p>One thing I've started doing more often recently is <strong>retrieving some data</strong> at the beginning of a task <strong>and storing it in a $_SESSION['myDataForTheTask']</strong>. </p>
  
  <p>Now it seems very convenient to do so but I don't know anything about performance, security risks or similar, using this approach. Is it something which is regularly done by programmers with more expertise or is it more of an amateur thing to do?</p>
  
  <p><strong>For example:</strong></p>
  
  <pre><code>if (!isset($_SESSION['dataentry']))
  {
      $query_taskinfo = "SELECT participationcode, modulearray, wavenum FROM mng_wave WHERE wave_id=" . mysql_real_escape_string($_GET['wave_id']);
      $result_taskinfo = $db-&gt;query($query_taskinfo);
      $row_taskinfo = $result_taskinfo-&gt;fetch_row();
  
          $dataentry = array("pcode" =&gt; $row_taskinfo[0], "modules" =&gt; $row_taskinfo[1], "data_id" =&gt; 0, "wavenum" =&gt; $row_taskinfo[2], "prequest" =&gt; FALSE, "highlight" =&gt; array());
  
          $_SESSION['dataentry'] = $dataentry;
  }
  </code></pre>