title: PHP Session variable isset(..)=1 after session_start()
body: <p>I guess I am not understanding the scope of session variables, or the session itself, in PHP, hence this question:</p>
  
  <p>This is my code</p>
  
  <pre><code>  if(session_id()!=""){
    echo "Getting rid of session"."&lt;/br&gt;";
    session_destroy();
   }
   echo "Before session_start(): ".isset($_SESSION["first_date_of_week"])."&lt;/br&gt;";
   session_start();
   echo "After session_start(): ".isset($_SESSION["first_date_of_week"])." ".$_SESSION["first_date_of_week"]-&gt;format("Y-m-d")."&lt;/br&gt;";
  </code></pre>
  
  <p>The output is: </p>
  
  <pre><code>Before session_start():
  After session_start(): 1 2011-01-09
  </code></pre>
  
  <p>How come that when doing the isset(..) on the session variable it is set directly after starting the session, even though I haven't even used it or set it yet? It does, however, still have the same value as before. </p>
  
  <p>Also, session_id()="" since the if-clause is never triggered. I never kill the session, how come it is set to ""? I.e. I refresh the page and expects the session to still be alive. </p>
  
  <p>Using the isset(..) function is then pretty useless testing if it has been set already... </p>
  
  <p>Thanks in advance!</p>
  
  <p>/Niklas</p>