title: PHP Session - not saving
body: <p>I'm working on an admin page for my site, but I found a problem. My code worked perfectly with Wamp (and still working in Chrome, but not for other people, or in other browsers).
  So, the problem is that my site don't save the session variable after header redirecting. (Another thing I can't figure out is, that if I put the die or exit after the header the page just go blank, and you must refresh manually. Still it's only on the webserver.)</p>
  
  <pre><code>&lt;?php
  session_start();
  $log = $_GET['logout'];
  $error = false;
  //logout
  if($log==true){
      unset($_SESSION['user']);
      header('Location: '.$_SERVER['PHP_SELF']);
      //die;
  }
  //login
  if (isset($_POST['submit']) &amp;&amp; !isset($_SESSION['user']) ){
      $file="login.xml";
      $xml=simplexml_load_file($file) or die ("Unable to load XMl file!");
      $nope=true;
      $givenuser = $_POST['username'];
      $givenpass = md5($_POST['password']);
      foreach($xml-&gt;user as $user){
          $username = $user-&gt;username;
          $password = $user-&gt;password;
          if ($givenuser == $username &amp;&amp; $givenpass == $password){
              $_SESSION['user'] = $givenuser;
              $nope =false;
              header('Location: '. $_SERVER['PHP_SELF']);
              //die();
          }
      }
      if($nope) $error = true;
  }
  //succesful login
  if (isset($_SESSION['user'])){
      ?&gt;
      &lt;html&gt;
      &lt;header&gt;&lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;&lt;/header&gt;
      &lt;body&gt;
      &lt;h1&gt;
      &lt;?php echo "Welcome ".$_SESSION['user']; ?&gt;
      &lt;/h1&gt;
      &lt;div&gt; 
          &lt;a href="?"&gt;New page&lt;/a&gt; 
          &lt;a href="?logout=true"&gt;Logout&lt;/a&gt;
      &lt;/div&gt;
      &lt;div id="menus"&gt;
          Pages:&lt;/br&gt;
          &lt;?php
              $file="../pages.xml";
              $xml=simplexml_load_file($file) or die ("Unable to load XMl file!");
              $index = 0;
              foreach($xml-&gt;xpath('//oldalneve') as $pagename){
                  echo '&lt;a href="?id='.$index.'"&gt;'.$pagename.'&lt;/a&gt;&lt;/br&gt;';
                  $index=$index+1;
              }
          ?&gt;
      &lt;/div&gt;
      &lt;?php
          if(!is_numeric($_GET['id'])){
              $id=-1;
          }else{
              $id=(int)$_GET['id'];
          }
          if($id!=-1){
              $id=(int)$_GET['id'];
              if(isset($_POST['name']) &amp;&amp; isset($_POST['body'])){
                  if($_REQUEST['name'] !="" &amp;&amp; $_REQUEST['body']!=""){
                      $file="../pages.xml";
                      $xml= simplexml_load_file($file) or die ("Unable to load XML file!");
                      $name = $_POST['name'];
                      $body = $_POST['body'];
                      $xml-&gt;page[$id]-&gt;oldalneve = $name;
                      $xml-&gt;page[$id]-&gt;body = $body;
                      $xml-&gt;asXML('../pages.xml');
                      header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id);
                      //die;
                      }
              }
              $file="../pages.xml";
              $xml= simplexml_load_file($file);
              $nam=$xml-&gt;page[$id]-&gt;oldalneve;
              $val=$xml-&gt;page[$id]-&gt;body;
              ?&gt;
              &lt;div style="float:left;"&gt;
                  &lt;form name="input" method="post" action="" &gt;
                      &lt;label&gt;Name&lt;/label&gt;&lt;/br&gt;
                      &lt;input type="text" name="name" style="width:250px" value="&lt;?php echo $nam;?&gt;"&gt;&lt;/br&gt;
                      &lt;label&gt;Body&lt;/label&gt;&lt;/br&gt;
                      &lt;textarea cols="28" rows="10" name="body"&gt;&lt;?php echo $val;?&gt;&lt;/textarea&gt;&lt;/br&gt;
                      &lt;input type="submit" name="submit" value="Küldés"&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;/body&gt;
              &lt;/html&gt;
              &lt;?php
          }else{ 
      ?&gt;
              &lt;div style="float:left;"&gt;
                  &lt;form name="input" method="post" action="" &gt;
                      &lt;fieldset&gt;&lt;legend&gt;Add page&lt;/legend&gt;
                          &lt;label&gt;Name&lt;/label&gt;&lt;/br&gt;
                          &lt;input type="text" name="name" style="width:250px"&gt;&lt;/br&gt;
                          &lt;label&gt;Body&lt;/label&gt;&lt;/br&gt;
                          &lt;textarea cols="28" rows="10"v name="body"&gt;&lt;/textarea&gt;&lt;/br&gt;
                          &lt;input type="submit" name="submit" value="Küldés"&gt;
                      &lt;/fieldset&gt; 
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;/body&gt;
              &lt;/html&gt;
              &lt;?php
              if(isset($_POST['submit'])){
                  if($_REQUEST['name'] !="" &amp;&amp; $_REQUEST['body']!=""){
                      $file="../pages.xml";
                      $xml= simplexml_load_file($file) or die ("Unable to load XML file!");
                      $page=$xml-&gt;addChild('page');
                      $name = $_POST['name'];
                      $body = $_POST['body'];
                      $page-&gt;addChild('oldalneve', $name);
                      $page-&gt;addChild('body', $body);
  
                      $xml-&gt;asXML('../pages.xml');
                      header('Location: '.$_SERVER['PHP_SELF']);
                      //die;
                  }
              }
          }
  }else
  {
      showLogin($error);
  }
  function showLogin($error){?&gt;
  
      &lt;form action="" method='post'&gt;
          &lt;label for="username"&gt;username&lt;/label&gt;
          &lt;input type="text" name="username" id="username"&gt;&lt;/br&gt;
          &lt;label for="password"&gt;password&lt;/label&gt;
          &lt;input type="password" name="password" id="password"&gt;&lt;/br&gt;
          &lt;?php
              if($error){
              echo "Invalid username or password".'&lt;/br&gt;';
              }
          ?&gt;
          &lt;input type="submit" name="submit" value="submit"&gt;
      &lt;/form&gt; 
  
  &lt;?php }
  
  ?&gt;
  </code></pre>
  
  <p>The user can login and see the interface, but using one of the links will redirect him to the login screen (Session user is not saved). </p>
  
  <p>Here is the phpinfo():</p>
  
  <pre><code>session.auto_start  Off Off
  session.bug_compat_42   On  On
  session.bug_compat_warn On  On
  session.cache_expire    180 180
  session.cache_limiter   nocache nocache
  session.cookie_domain   no value    no value
  session.cookie_httponly Off Off
  session.cookie_lifetime 0   0
  session.cookie_path /   /
  session.cookie_secure   Off Off
  session.entropy_file    no value    no value
  session.entropy_length  0   0
  session.gc_divisor  100 100
  session.gc_maxlifetime  1440    1440
  session.gc_probability  1   1
  session.hash_bits_per_character 4   4
  session.hash_function   0   0
  session.name    PHPSESSID   PHPSESSID
  session.referer_check   no value    no value
  session.save_handler    files   files
  session.save_path   /tmp    /tmp
  session.serialize_handler   php php
  session.use_cookies On  On
  session.use_only_cookies    Off Off
  session.use_trans_sid   0   0
  </code></pre>