title: PHP Session variable changing from page to page
body: <p>I'm using a session variable to save the last page the user visited in the search results so that they can go back to that page.</p>
  
  <p>if I make </p>
  
  <pre><code>echo($_SESSION['page'])
  </code></pre>
  
  <p>at he end of the results pages the value is correct, but when I reload the page (or load any other page) the value is increased by 1. I made a <code>echo($_SESSION['page'])</code> right after the <code>session_start()</code> call and it was already increased, so I guess it's been increased right before the PHP code for the search results finishes running but can't find the line of code that is doing so.</p>
  
  <p>In order to test this added a new variable called <code>$_SESSION['page2']</code> and this new variable is been increased too.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT</p>
  
  <p>The variable is taking the value from a Pager object like this</p>
  
  <pre><code>$_SESSION['page'] = $pager-&gt;getCurrentPageID();
  </code></pre>
  
  <p>And I can't find any other place where its been set to a different value. We use the same unit and code in a different site and never had this problem before. Tried replacing the code and the Pager class definition with those from the other site and that didn't fix it.</p>