title: php session lost after submitting form
body: <p>The code below page keeps session on GET requests or refreshing browser, but when I submit a form the session data is lost.</p>
  
  <pre><code>$user=$_POST['user']; $pass=$_POST['pass'];
  if ($_POST['user'])
  { if($user==$un and $pass=$pw)
    { $_SESSION['uid']=$Xid;header('Location: '.$uri.'?welcome'); }
    else { $msg="chybny login";  }
  }
  
  if(isset($_GET['logout']))   { session_destroy(); header('Location: '.$uri); }
  $cnt=$_SESSION['cnt']+1; $_SESSION['cnt']=$cnt;
  </code></pre>
  
  <p>Above is the code for login which re-directs me to the welcome page as it was verified, however the session is lost. If I just refresh or repeatedly load the page without submitting, the session holds by echoing the session variable cnt (counts up 1,2,3,...)</p>
  
  <p>After submitting the form, I see session is lost and too cnt variable is reset?</p>