title: session value is not the correct value
body: <p>I am trying to pass a session variable from one page to another but it keeps returning the same value of '2' I am not entirely sure where this value is coming from though.</p>
  
  <p>I am setting the value inside of a funtion to get the id of the value from the dashboard set into the session.</p>
  
  <pre><code>function listDashboards() {
  global $conn;
  
  
      $sql = "SELECT * FROM dashboards";
          $result = $conn-&gt;query($sql);
  
          if($result-&gt;num_rows &gt; 0){
              while($row = $result-&gt;fetch_assoc()){
  
                  $_SESSION['dansDashboardId'] = $row["dashboard_id"]; // HERE
  
                  echo $_SESSION['dansDashboardId']; // AND HERE
  
                  echo '&lt;div class="dashboardListRow"&gt;';
                  echo '&lt;a href="../index.php"&gt;' . $row["dashboard_name"] . '&lt;/a&gt;';
                  echo '&lt;button&gt;View Dashboard&lt;/button&gt;';         
                  echo '&lt;a href="dashboard.php?dashboard_id=' . $row["dashboard_id"] . '"&gt;' . '&lt;button&gt;Manage Dashboard&lt;/button&gt;&lt;/a&gt;';            
                  echo '&lt;/div&gt;';
  
              }
          } else{
              header('Location: create-dashboard.php');
          }
  
      }
  </code></pre>
  
  <p>When I click on the link to the <code>,,/index.php</code> file inside of the loop I want to then echo out the session variable on that page but ist just keeps returning '2'</p>
  
  <p><code>$dashboardIdNew = $_SESSION['dansDashboardId'];</code></p>
  
  <p><code>echo $dashboardIdNew</code> just returns <code>2</code></p>
  
  <p>However, if I echo out that session inside of the loop it returns the correct values</p>