How to hide the cookies.txt from curl

0

Ihaveacodeinphpthatmakesarequestwithcurlonapage,howeveritsavesthecookiesinatextfilecookies.txt,andanyonecanhaveaccesstothisfileinadirectlink" www.mysite.com .com.br / cookies.txt "I want to know how to hide this, because the security of my application would be jeopardized if someone finds this file.

    
asked by anonymous 31.10.2017 / 15:42

1 answer

1

There are already a number of site posts on how to block an external client from accessing a file.

For example, if it is an Apache server:

  

link

Better than this would be to change the path where the file is saved, putting it outside the root of your hosting (for example, outside the httpdocs directory or equivalent):

curl_setopt( $curl_handle, CURLOPT_COOKIEJAR, caminho );
curl_setopt( $curl_handle, CURLOPT_COOKIEFILE, caminho );
  • CURLOPT_COOKIEFILE is the path where cookies is stored and read during normal usage.

  • CURLOPT_COOKIEJAR is the path where cookies is stored after calling the cleanup function.

See the cURL for PHP options in the manual:

  

link

    
01.11.2017 / 16:32