title: PHP function can not be called
body: <p>I have a link in page A that directs to page B. page B has a function like this:</p>
  
  <pre><code>function s(){
      $_SESSION['active']='0';
  }
  s();
  echo $_SESSION['active'];
  </code></pre>
  
  <p>The problem is that in order for  function s() to be called and <code>$_SESSION['active']</code> be set, I need a second refresh, and this adds some overhead. I don't know why this function is not called when directing from page  A to B? any help would be appreciated.</p>
  
  <p>EDIT 1: I have session_start(); at the very top of every php script. the only solution I could come up with is a second refresh </p>
  
  <p>EDIT 2: I have inspected the code very carefully, echoing every variable in my function and also using XDEBUG. the problem is as I stated, when directing to page B the function is not called until I refresh the page.</p>
  
  <p>EDIT 3: Problem solved. it was a very stupid mistake, that session variable was unset somewhere in the code preceding that function. that problematic function was part of nested functions, and I am using circular references in number of functions which makes my code hard to read, That is why I could't post here. Thanks ever one, it is really a shame. </p>