CURLOPT_COOKIEFILE vs CURLOPT_COOKIEJAR
CURLOPT_COOKIEFILE: The name of the file containing the cookie data. The cookie file can be in Netscape format, or just plain HTTP-style headers dumped into a file.
CURLOPT_COOKIEJAR: The name of a file to save all internal cookies to when the connection closes.
# Sẽ lấy cookie có trong file để gửi request đi
curl_setopt($curl, CURLOPT_COOKIEFILE, ‘cookie_will_be_used.txt’);
# Sẽ lưu cookie server response về
curl_setopt($curl, CURLOPT_COOKIEJAR, ‘cookie_will_be_saved.txt’);