title: Embeded PHP is being called on page exit
body: <p>I am using php session and it <strong><em>seems</em></strong> the embedded code is being called when I am changing pages. When adding the embedded code it causes my logout function to misbehave, resulting in the logout function acting as if the user is logged out instead of acting like the user is logged in.</p>
  
  <p>Index.php:</p>
  
  <pre><code>&lt;a href="inc/Log_in_out.php"&gt;&lt;button&gt;Login/Logout&lt;/button&gt;&lt;/a&gt;
  ...
  var x;
  
  function timedCount() {
  
  
      if (isLogged == 1) {
          x = setTimeout(function(){TimeMeOut();}, timeLeft*1000);
  
       }   
  }
  
  function TimeMeOut() {
      //Embeded PHP Code being called
      // Removing this code makes the logout work perfectly fine
  
      &lt;?php
      //Set session empty
      $_SESSION['user'] = '';
  
      // remove all session variables
      session_unset(); 
  
      // destroy the session 
      session_destroy(); 
      ?&gt;
  
      location.reload();
      alert('You where logged out.');
  }
  </code></pre>
  
  <p>Here is the second page. What should happen when this page is called is that it redirects me to Index.php but instead I am redirected to Login.php. However like mention before when I remove the embedded code this page functions as normal.</p>
  
  <p>Log_in_out.php:</p>
  
  <pre><code>&lt;?php
  session_start();
      if(isset($_SESSION['user'])) {
              /* When Already Logged In*/
  
              //Set Cookie to false
              $_SESSION['user'] = '';
  
              // remove all session variables
              session_unset(); 
  
              // destroy the session 
              session_destroy(); 
  
              //change page
              header("Location: http://cornelis.website/GeoLocationSite/Index.php"); /* Redirect browser */
  
  
          } else {
              /* When user is logged out*/
              header("Location:http://cornelis.website/GeoLocationSite/Login.php"); /* Redirect browser */
  
          }
  ?&gt;
  </code></pre>