title: Passing SESSION with CURL
body: <p>I'm pretending to pass a <code>COOKIE_FILE</code> to another script because I'm using php Curl to make some petitions and I need some of the <code>SESSION</code> variables there, in the main script I have:</p>
  
  <pre><code>       define("COOKIE_FILE", "cookie.txt");
          $options = array(
              CURLOPT_HEADER =&gt; false,
              CURLOPT_TIMEOUT =&gt; 40000
          );
  
          $params=['Variable1'=&gt;$initial, 'Variable2'=&gt;$this-&gt;V2];
          $defaults = array(
              CURLOPT_URL =&gt; 'localhost/socket/src/myApp/socket2.php',
              CURLOPT_POST =&gt; true,
              CURLOPT_POSTFIELDS =&gt; http_build_query($params),
              CURLOPT_COOKIEJAR =&gt; COOKIE_FILE,
              CURLOPT_COOKIEFILE =&gt; COOKIE_FILE,
              );
          $ch = curl_init();
          curl_setopt_array($ch, ($options + $defaults));
          curl_exec($ch);
  </code></pre>
  
  <p>This is the complete code of the script that calls socket2:</p>
  
  <pre><code>&lt;?php
  namespace MyApp;
  use funciones;
  use Agente;
  use Ratchet\MessageComponentInterface;
  use Ratchet\ConnectionInterface;
  
  define("COOKIE_FILE", "cookie.txt");
  $_SESSION["running"] = time();
  
  class Chat implements MessageComponentInterface {
      protected $clients;
      protected $data_clients;
      protected $target = "999999"; 
  
  
      public function __construct() {
          $this-&gt;clients = new \SplObjectStorage;
          $this-&gt;data_clients = new \SplObjectStorage;
          $this-&gt;send_message('testing from php');
          $this-&gt;Listen(true);
      }
  
      public function onOpen(ConnectionInterface $conn) {
          // Store the new connection to send messages to later
          $this-&gt;clients-&gt;attach($conn);
          echo "New connection! ({$conn-&gt;resourceId})\n";
      }
  
  
      public function Listen($initial){
         $band=false;
  
         $options = array(
              CURLOPT_HEADER =&gt; true,
              CURLOPT_TIMEOUT =&gt; 40000
          );
  
          $params=['initial'=&gt;$initial, 'target'=&gt;$this-&gt;target'];
          $defaults = array(
              CURLOPT_URL =&gt; 'localhost/socket/src/myApp/socket2.php',
              CURLOPT_POST =&gt; true,
              CURLOPT_POSTFIELDS =&gt; http_build_query($params),
              CURLOPT_COOKIEJAR =&gt; COOKIE_FILE,
              CURLOPT_COOKIEFILE =&gt; COOKIE_FILE,
              );
  
          //Tell cUrl about the cookie file
          //curl_setopt($ch,CURLOPT_COOKIEJAR, $this-&gt;cookieFile);  //tell cUrl where to write cookie data
          //curl_setopt($ch,CURLOPT_COOKIEFILE, $this-&gt;cookieFile); //tell cUrl where to read cookie data from
  
          $ch = curl_init();
          curl_setopt_array($ch, ($options + $defaults));
          curl_exec($ch);
  
          if(curl_errno($ch)){
              $band=true;
          }
          curl_close($ch);
  
          if(!$band)
              $this-&gt;Listen(false);
      }//fin Listen
  
      public function get_messages(){
  
          $band=false;
          $options = array(
              CURLOPT_HEADER =&gt; false,
              CURLOPT_TIMEOUT =&gt; 1000
          );
  
          $params=['method'=&gt;'pollMessages'];
          $defaults = array(
              CURLOPT_URL =&gt; 'localhost/socket/src/myApp/ajax2.php',
              CURLOPT_POST =&gt; true,
              CURLOPT_POSTFIELDS =&gt; http_build_query($params),
          );
          $ch = curl_init();
          curl_setopt_array($ch, ($options + $defaults));
          curl_exec($ch);
  
          if(curl_errno($ch)){
              $band=true;
          }
          curl_close($ch);
  
          if(!$band)
              $this-&gt;get_messages();
      }//fin de get messages
  
   public function send_message($mensaje){
  
          $band=false;
          $options = array(
              CURLOPT_HEADER =&gt; false,
          );
  
          $params=['method'=&gt;'sendMessage','target'=&gt;$this-&gt;target,'message'=&gt;$mensaje];
          $defaults = array(
              CURLOPT_URL =&gt; 'localhost/socket/src/myApp/ajax2.php',
              CURLOPT_POST =&gt; true,
              CURLOPT_POSTFIELDS =&gt; http_build_query($params),
          );
          $ch = curl_init();
          curl_setopt_array($ch, ($options + $defaults));
          curl_exec($ch);
        /*  $headerSent = curl_getinfo($ch, CURLINFO_HEADER_OUT ); // request headers
      echo $headerSent;*/
          curl_close($ch);
  
      }//fin de enviar mensaje
  </code></pre>
  
  <p>in socket2.php I have:</p>
  
  <pre><code>&lt;?php
      require  '../../vendor/autoload.php';
      set_time_limit(10); //1 minute
      session_start();
      session_write_close();
  
      $time = $_SESSION["running"];
  ?&gt;
  </code></pre>
  
  <p>I'm trying to read the variable <em>running</em>
  But I still get in the other side (<em>socket2.php</em>) <code>Undefined index:running</code> for the SESSION variable that I'm needing. So, What am I missing? How I check that the file <em>cookie.txt</em> is created sucesfully? Thanks</p>