title: session_start() php variables
body: <p>I am trying to authenticate a user log in system from the PHP server side. I have been stuck on this for a few weeks now and can't seem to find my answer online anywhere. I hope that you guys can help me out.</p>
  <p>Every time I call the php script the session variables seem to be lost. Here are the logs from my php server:</p>
  <pre><code>[Sun Nov  8 14:28:16 2020] 127.0.0.1:60706 [200]: /api/read.php
  [Sun Nov  8 14:28:27 2020] Session Variables set!
  [Sun Nov  8 14:28:27 2020] admin
  [Sun Nov  8 14:28:27 2020] 127.0.0.1:60713 [200]: /api/read.php
  [Sun Nov  8 14:54:34 2020] Session Variables set!
  [Sun Nov  8 14:54:34 2020] admin
  </code></pre>
  <p>I am calling a php script from the same page multiple times by calling it from a typescript file:</p>
  <pre><code>readRecruitmentNeeds(): Observable&lt;Policy[]&gt;{
    return this.httpClient.get&lt;Policy[]&gt;(`${this.PHP_API_SERVER}/api/read.php`);
  }
  </code></pre>
  <p>The php script has a session_start() with the variable name $_SESSION['uname']:</p>
  <pre><code>session_start();
  
  $username=&quot;admin&quot;;
  $pwd=&quot;admin&quot;;
  
  if(isset($_SESSION['uname'])){
    readData();  //run if logged in
    error_log (&quot;User is logged in&quot;,0);
    error_log ($_SESSION['uname'],0);
  }
  else{
    $_SESSION['uname']=$username;
    error_log (&quot;Session Variables set!&quot;,0);
    error_log ($_SESSION['uname'],0);
    
  }
  </code></pre>
  <p>Any help is appreciated. Thanks!</p>