title: how to end php session and begin a new one when user chooses action
body: <p>This relates to my question <a href="https://stackoverflow.com/questions/32740496/make-php-form-generated-variable-available-in-two-php-files">here</a>, which had to do with making variables usable in multiple php files. Both Ian Hildebrand and Transcendental offered useful advice.</p>
  
  <p>I want to let a user select, say, 6 a.m. from a form and view data pertaining to that hour, in either or both of two views, View_A and View_B. If the user then wants to look at data from 7 a.m. then he/she just reloads the form and selects that hour and submits.</p>
  
  <p>What happens now is that the variable $hour stays stuck at 6 a.m. So the user can select whatever hour he/she wishes but still gets 6 a.m. data.</p>
  
  <p>So what I want is, when the user selects the new hour, that action ends the first session and starts a new one.</p>
  
  <p>here's the applicable code from the form file:</p>
  
  <pre><code>   &lt;form action='view_A.php' method='post'&gt;
          &lt;label for 'date'&gt;&lt;strong&gt;Select an hour for &lt;?php echo $date; ?&gt;&lt;/strong&gt;
          &lt;/label&gt;
          &lt;input type="text" name='hour' data-role="datebox" data-options='{"mode":"timeflipbox","minuteStep":60, "overrideTimeFormat": "%H", "overrideTimeOutput": "%H"}' placeholder='click icon to select hour'&gt;
          &lt;input type='submit' name='submit' value='submit'&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  &lt;?php
  if(isset($_POST[ 'submit'])) { 
  $_SESSION[ 'hour']=$ _POST[ 'hour']; 
  $hour=$ _SESSION[ 'hour']; }
  ?&gt;
  </code></pre>
  
  <p>... and applicable code in the file view_A.php</p>
  
  <pre><code>session_start();
  error_reporting(E_ALL);
  include ("db_connect.php");
  date_default_timezone_set('America/Toronto');
  $date = date('Y-m-d');
  $hour =     $_SESSION['hour'];
  $blink = $_SESSION['hour'];
  $date_hour = $date.' '.$hour;
  </code></pre>
  
  <p>Both these files lead off with <code>session_start();</code> right after the opening php tag.</p>
  
  <p>How could I modify the form file so that when the user selects a new hour the current  session ends and a new one starts?</p>