title: PHP session is restarting instead of resuming
body: <p>I am unity3d to make a login/logout screen for my game. I am assigning values to the session variable during login. It is working fine in the browser but if i call the logout from unity it always says "user not logged in". </p>
  
  <p>It means the session variable is going back to NULL or the session is restarting inside the logout.php instead of resuming. How do i solve this?</p>
  
  <p>Login.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
   $servername="localhost";
   $username="root";
   $password="xxxx";
   $database="database";
  
  try {
      $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
      // set the PDO error mode to exception
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      // =============================================================================
      $unityHash = $_POST["unity_hash"];
      $phpHash = "hashcode"; // same code in here as in your Unity game
  
      $player = $_POST["form_name"]; //I use that function to protect against SQL injection
      $password = $_POST["form_password"];
  
      if(!$player || !$password) {
          echo "Login or password cant be empty.";
      } else {
          if ($unityHash != $phpHash){
              echo "HASH code is diferent from your game, you infidel.";
          } else {
              $sql = $conn-&gt;prepare("SELECT password FROM players WHERE player = '$player' LIMIT 1");
              $sql-&gt;execute();            
              if($sql-&gt;rowCount() &gt; 0)
              {
                      $row = $sql-&gt;fetch(PDO::FETCH_ASSOC);
                      if(password_verify($password, $row['password'])){
                          echo "successfully logged in";
                          //update the state
                          $stmt = $conn-&gt;prepare("UPDATE players SET state='1' WHERE player= '$player' AND password = '$row[password]'");
                          $stmt-&gt;execute();   
  //SESSION VARIABLE ASSIGNMENT  
                              $_SESSION["form_name"] = $player;
                              $_SESSION["form_password"] = $row['password'];
  
                          }
                          else{
                          echo "Wrong password";
                          }
  
                  }
                  else{
                      echo "Data invalid - cant find name.";
                  }               
              }
          }
          }
      catch(PDOException $e)
          {
          echo "Error: " . $e-&gt;getMessage();
          }
  
      $conn = null;
      ?&gt;
  </code></pre>
  
  <p>Logout.php</p>
  
  <pre><code>&lt;?php
  session_start();
  echo $_SESSION["form_password"];
  
  if(isset($_SESSION["form_name"])){
      unset($_SESSION["form_name"]);
      unset($_SESSION["form_password"]);
      echo "successfully logged out"; 
  }
  
  else{
  echo "user not logged in"; 
  }        
  ?&gt;
  </code></pre>
  
  <p>I am getting the following error if i try to print $_SESSION["form_password"]</p>
  
  <p><code>&lt;b&gt;Notice&lt;/b&gt;:  Undefined index: form_password in &lt;b&gt;C:\xampp\htdocs\aditya\logout.php&lt;/b&gt; on line &lt;b&gt;3&lt;/b&gt;&lt;br /&gt;</code> </p>
  
  <p>Code inside unity</p>
  
  <pre><code>IEnumerator LoginUser(){
          WWWForm form = new WWWForm();
          form.AddField("form_name" , form_name);
          form.AddField("form_password" , form_password );
          form.AddField("unity_hash" , unity_hash);
  
          WWW login = new WWW(login_url, form);
  
          yield return login;
  
          // check for errors
          if (login.error == null)
          {
              Debug.Log(login.text);
  
          } else {
              Debug.Log("WWW Error: "+ login.error);
          } 
      }
  
      IEnumerator LogoutUser(){
  
          WWW logout = new WWW(logout_url);
  
          yield return logout;
  
          // check for errors
          if (logout.error == null)
          {
              Debug.Log(logout.text);
  
          } else {
              Debug.Log("WWW Error: "+ logout.error);
          } 
      }
  </code></pre>