title: Session in PHP server for Android app
body: <p>I am trying to create a session to retrieve the login username for further usage, which is to create a directory name based on the login username.
  It is an app connect to the php server 
  I am able to connect to the database. Login successfully. Creating the directory is successful too(in separated android project)</p>
  
  <p>When I try to add in session_start in the mkdir.php file. My login failed (even the individual project which contains the login function ONLY to the same database failed.)Login only works again once I remove the session_start from mkdir.php).Not only that, the app which contains login function is force to close.Other apps related to the same database was affected too.</p>
  
  <p>Please guide.The problem is on the mkdir.php I guess</p>
  
  <p><strong>FAILED</strong>: mkdir.php</p>
  
  <pre><code>&lt;?php 
   include "Header.php";
   include "localhost.php"; 
   include "main.php"; 
  
   $path = $_Session['username'].$_POST['Case_no'];
   mkdir($path);
  
   ?&gt;
  </code></pre>
  
  <p>Header.php</p>
  
  <pre><code>&lt;?php   session_start();
  include "localhost.php"; 
  
   if(!isset($_SESSION['username']))
   {
      ?&gt;
       &lt;a href="Login.php" /&gt;Login &lt;/a&gt;
      &lt;?
   }
   else 
   {
    echo "welcome ".$_SESSION['username'];
  
    ?&gt;
     &lt;a href="Logout.php" /&gt;Logout &lt;/a&gt;
    &lt;?
   }
  
       ?&gt;
  </code></pre>
  
  <p>localhost.php is the connection to the database(it works)</p>
  
  <p>main.php</p>
  
  <pre><code>&lt;?php require_once('localhost.php'); mysql_select_db($database_localhost,$localhost);
  
  
  
   $username = $_POST['UserEmail'];
  
   $password = $_POST['Password'];
  
  
  
   $query_search = "select * from tbl_user where username = '".$username."' AND password = '".$password. "'";
  
   $query_exec = mysql_query($query_search) or die(mysql_error());
  
   $rows = mysql_num_rows($query_exec);
  
    $_SESSION['username']=$username;
  
  
   ?&gt;
  </code></pre>
  
  <p><strong>SUCCESSFUL</strong> :mkdir.php</p>
  
  <pre><code>&lt;?php
   $path = $_POST['Case_no'];
   mkdir($path);
  
   ?&gt;
  </code></pre>