title: PHP How to stop Chrome loading a page twice
body: <blockquote>
    <p>Note: I have updated and rewritten my question to try and solve this issue point by point. Cheers.</p>
  </blockquote>
  
  <p>I have a problem and I'm not immediately sure how to go about resolving it. </p>
  
  <p>I have been building a secured login system on a HTTPS server (with a grade of "A" by SSL-labs, if that's worth anything ), and it works fine, however today it is refusing to log me in, with some debugging I have found something very odd (in my view).</p>
  
  <p>I have some serious issues with session handling on the website, the different pages use the same session data (of course) and the same session /cookie settings, and they pass the information between each other correctly, <strong>BUT</strong> the behaviour of my browser appears to be as if there are two browsers visiting the same websites, using the same session data. </p>
  
  <p>Symptoms - Because I have been having inconsistencies with page generated session content (unique hash token) not fitting the same data saved in the login form (as a <code>$_POST</code> value), I was finding that as there is only one line in the whole site that sets the value of the session, this line must be running twice. So I set a counter value in the session, on the form page as <code>session['counter']</code>. each time the page loads, the counter +1's. My problem is specifically with this:</p>
  
  <p><strong>Login page:</strong> </p>
  
  <pre><code>Opens page,  
  session hash-string is generated and saved to the post form.
  session counter = counter + 1;
  Form is filled in.
  </code></pre>
  
  <p><strong>Login auth' page:</strong> </p>
  
  <pre><code>fails to verify the posted hash-string is the same as the session hash
   string, despite there being no other cause for the session values to
   change (well there must be, but I can't see it!)  
  </code></pre>
  
  <p>But, then going back to the <em>Login Page</em> I see that the counter = last value + 2! Also, the counter value <em>recorded on the session file saved on the server</em> is always +1 to the value displayed on the login page. </p>
  
  <p>Some images:</p>
  
  <p><a href="https://i.stack.imgur.com/v6jzt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v6jzt.jpg" alt="enter image description here"></a></p>
  
  <p>Login Form Page: Please note that this is above the HTML output and is the <strong><em>last place on the code where any SESSION data is edited</em></strong>.</p>
  
  <p>Output :</p>
  
  <p><a href="https://i.stack.imgur.com/7qq4t.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7qq4t.jpg" alt="enter image description here"></a></p>
  
  <p>Please note the number relating to the counter in image 1.</p>
  
  <p><a href="https://i.stack.imgur.com/qZIiY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qZIiY.jpg" alt="enter image description here"></a></p>
  
  <p>My session file, this file relates to this specific browser session and only 1 session file as I am the only browser on the site. </p>
  
  <p><a href="https://i.stack.imgur.com/wxFAZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wxFAZ.jpg" alt="enter image description here"></a></p>
  
  <p>The string <code>CheckDrop</code> is the hash value to compare but the counter is at <strong>12</strong> rather than 11, which is displayed in image 2 above. </p>
  
  <ul>
  <li><p>My site is HTTPS authed although this work is on a subdomain.</p></li>
  <li><p>This issue has been happening for the last 3 hours but <em>inconsistently</em>, it magically worked for about 40 minutes earlier today (just before posting this post). but I had done nothing I could see as changing the environment. </p></li>
  <li><p>I have previously compared phpinfo data and session setup data it all looks correct at point of browser output. It does not seem to be caused by my settings.</p></li>
  <li><p>It happens on different browsers on my PC.</p></li>
  </ul>
  
  <h2>Further Work</h2>
  
  <p>After spending hours debugging and working through this, it appears to be a browser issue. I have renamed the pages (one page was called index while it was not defined in .htaccess as the directory listing page which may have <em>possibly</em> caused a browser to open it twice).</p>
  
  <p>I have cleared all associated data: sessions / database records / browser history, and have come across something:</p>
  
  <p>Firefox now logs in as expected, the counter is count+1 and the login works, however on Chrome the exact same log in on the same pages does not work and the browser appears to load twice, the <code>counter = counter + 2</code>. Chrome also leaves two records in the database at each load rather than the expected one. </p>
  
  <p>Chrome version 45.0.24
  Firefox version 42.0 </p>
  
  <p>Page double counts and runs script twice on <strong>Safari</strong> and <strong>Chrome</strong>. On Firefox, Opera and MSIE it works as intended. </p>
  
  <p><strong>Any ideas why this is occurring</strong>? </p>
  
  <p><strong>How can I go about trying to solve this problem?</strong></p>