title: Website not being able to login into the REST application
body: <p>I am developing a web application. My main application is a REST application. Unlike traditional web development, my website connects to my rest application to POST, DELETE, PUT or GET data. </p>
  
  <p>Now, when i POST my username and password to my REST application through a desktop application called Postman(<a href="https://www.getpostman.com/" rel="nofollow">https://www.getpostman.com/</a>) and then GET the account data, it works perfectly fine and I am able to retrieve the data.</p>
  
  <p>But when my website connects to my REST app through cURL library. It is not able to GET any data because the website shows not logged in.</p>
  
  <p>I don't know why Postman and my website are behaving differently even though they are getting data from same REST application.</p>
  
  <p>Note that the sessions are in REST application only, so my website doesnt use any native sessions.</p>
  
  <p>Here are my functions in my website:</p>
  
  <pre><code>function process_api_get($base_url,$extension)
  {
      $curl = curl_init();
  curl_setopt_array($curl, array(
      CURLOPT_RETURNTRANSFER =&gt; 1,
      CURLOPT_URL =&gt; $base_url . $extension,
          CURLOPT_CUSTOMREQUEST =&gt; 'GET'
  ));
  
  $resp = curl_exec($curl);
  curl_close($curl);
  
   // echo '&lt;pre&gt;';
   // print_r($resp);
   // exit;
  
  return json_decode($resp);
  }
  function process_api_post($input,$base_url,$extension)
  {
      $obj = json_encode($input);
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");   
      curl_setopt($ch, CURLOPT_POSTFIELDS, $obj);       
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
      curl_setopt($ch, CURLOPT_COOKIESESSION, true);   
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0');
  
      curl_setopt($ch, CURLOPT_URL, $base_url . $extension);
  //    
      if (isset($_COOKIE[session_name()]))
          curl_setopt($ch, CURLOPT_COOKIE, session_name().'='.$_COOKIE[session_name()].'; path=/');
  
      session_write_close();
  
      $result = curl_exec($ch);
  
  
      curl_close($ch);
  
    return json_decode($result); 
  }
  
  function process_api_put($input,$base_url,$extension)
  {
  
    $obj = json_encode($input);
      $ch = curl_init();
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");   
    curl_setopt($ch, CURLOPT_POSTFIELDS, $obj);       
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0');   
      curl_setopt($ch, CURLOPT_URL, $base_url . $extension);
    if (isset($_COOKIE[session_name()]))
         curl_setopt($ch, CURLOPT_COOKIE, session_name().'='.$_COOKIE[session_name()].'; path=/');
  
    session_write_close(); 
      $result = curl_exec($ch);
      curl_close($ch);
      session_start();
    return json_decode($result); 
  
  }
  function process_api_delete($input,$base_url,$extension)
  {
      $obj = json_encode($input);
      $ch = curl_init();
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");   
    curl_setopt($ch, CURLOPT_POSTFIELDS, $obj);       
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_URL, $base_url . $extension);
      $result = curl_exec($ch);
      curl_close($ch);
    return json_decode($result); 
  }
  </code></pre>