title: php - How can I identify refresh from any other type page change
body: <p>I am using php code to create and update an SQL database which I, in turn, use to populate an on-screen page counter (see code snippet below).  How can I differentiate a page refresh from any other url change so as not to add to my counter every time the page is refreshed?  I want to do this without putting cookies on my user's desktop.  Thanks in advance for your help.</p>
  
  <pre><code>include("incPHP1.inc");
  $cxn=mysqli_connect($host,$user,$password,$database)
      or die ("Couldn't connect to the server.");
  $result = mysqli_query($cxn, "SELECT * FROM visitors");
  $counter = mysqli_num_rows($result);
  $views = $counter;
  </code></pre>
  
  <p>Cosmin: </p>
  
  <p>I copied the code as you have written it into the first line of my php code (see first attempt code below).  It did not work in either IE11 or Firefox 55.0.3.  In both cases, I got an error message (Fatal error: Function name must be a string in D:\InetPub\vhosts\rlcdev.com\httpdocs\index.php on line 2) and no output.  I removed the initial $session_name(); command line and left it out (see second attempt code below).  This was because I understand that the $session_start(); command must be the first line after the 
  
  <p>First Attempt:</p>
  
  <pre><code>&lt;?php
  $session_name();
  $session_start();
  $_SESSION['refresh'] = isset($_SERVER['HTTP_CACHE_CONTROL'])  &amp;&amp; $_SERVER
  
  ['HTTP_CACHE_CONTROL'] === 'max-age=0';
  if($_SESSION['refresh'])
  {
              echo ("&lt;SCRIPT&gt;alert ( 'Page has been refreshed, The AJAX call was not made');&lt;/SCRIPT&gt;");
  }
  else
  {
                  echo ("&lt;SCRIPT&gt;alert ( 'This is a non-refresh reload' );&lt;/SCRIPT&gt;");
  }
  </code></pre>
  
  <p>Second Attempt:</p>
  
  <pre><code>&lt;?php
  $session_start();
  $_SESSION['refresh'] = isset($_SERVER['HTTP_CACHE_CONTROL'])  &amp;&amp; $_SERVER
  
  ['HTTP_CACHE_CONTROL'] === 'max-age=0';
  if($_SESSION['refresh'])
  {
              echo ("&lt;SCRIPT&gt;alert ( 'Page has been refreshed, The AJAX call was not made');&lt;/SCRIPT&gt;");
  }
  else
  {
                  echo ("&lt;SCRIPT&gt;alert ( 'This is a non-refresh reload' );&lt;/SCRIPT&gt;");
  }
  </code></pre>