title: Laravel cURL won't write cookie file
body: <p>I have found many questions like mine, unfortunately without a working for me solution. I have created a function for crawling websites, but for some websites I need to set some cookies to get the relevant content. 
  My website is using framework Laravel 5.2 and the problem is that it does not save a cookie file to the storage path (or to the public too).</p>
  
  <p>Years ago on non Laravel site I was using the same function and there was no problem to create the cookies file.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>function getFileContentByCurl($strURL, $objPost = "", $strReferrer = "", $objHeaders = "", $strCookie = "") {
  
          $ch = curl_init(); 
          curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0");
          curl_setopt($ch, CURLOPT_URL, $strURL);
          curl_setopt($ch, CURLOPT_VERBOSE, 1);
          curl_setopt($ch, CURLOPT_COOKIESESSION, true);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          // curl_setopt($ch, CURLOPT_HEADER, true);
  
          $cookie_file = storage_path('app/cookies.txt');
  
          if($strCookie) {
              curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); 
              curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
          }   
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
          curl_setopt($ch, CURLOPT_BUFFERSIZE, 65536);
          curl_setopt($ch, CURLOPT_ENCODING, "");
  
          if($strCookie != "") {curl_setopt($ch, CURLOPT_COOKIE, $strCookie);}
          if($strReferrer != "") {curl_setopt($ch, CURLOPT_REFERER, $strReferrer);}
          if($objHeaders != "") {curl_setopt($ch, CURLOPT_HTTPHEADER, $objHeaders);}
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
          if($objPost != ""){curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $objPost);}
          $returned = curl_exec($ch);
  
          curl_close($ch);
          sleep(5);
          return $returned;
  
  }
  </code></pre>
  
  <p>I have tried to put an empty file in the storage directory, but it does not write in it. Have checked if the file is writable and it is.</p>