title: $_SESSION is empty when calling an api rendered with React
body: <p><strong>Context</strong>:
  I have an api that is rendered with React. When I log in and I go to the admin page, I only want to see my own content, created by me and only me. To do so, I must check if my <code>$_SESSION['user_id']</code> matches the publisher_id in my database. The api allows the logged in user to create/delete/edit his post. The structure for the api is :</p>
  
  <ol>
  <li>post.php where we create a class called Post with multiple methods ( create,edit etc ).</li>
  <li>create.php , edit.php , read.php etc where we create a Post object and call the function we require for the action wanted.</li>
  </ol>
  
  <p>The latter then is called in one of the components in React called Create.js etc which will then be rendered after being encapsulated in other components.</p>
  
  <p><code>$_SESSION['user_id']</code> is absent until after React finishes rendering all of our posts.</p>
  
  <p>When I call echo $_SESSION['user_id'] right before my React container on the content.php page, the user_id will show up correctly. ( I use <code>session.start()</code> at the top of the page ) </p>
  
  <pre><code>&lt;?php
  echo $_SESSION['user_id']; // works
  
  //Container for our React component.When calling the api inside the 
  //component, $_SESSION['user_id'] is empty
  echo "div id='app'&gt;&lt;/div&gt;";
  
  
  echo $_SESSION['user_id']; //works again, $_SESSION['user_id'] is the same as before
  </code></pre>
  
  <p><strong>Problem:</strong>
   When React renders the content from my database, nothing will show up if in my SQL query I write "<code>... WHERE p.publisher_id=" . $_SESSION['user_id'] .</code> " ... " which means that <code>$_SESSION['user_id']</code> is not there anymore.</p>
  
  <p>Any suggestions on how can I fix it?</p>