I have a php file that does http requests and needs cookies to work.
I've specified the cookies in the curl options with an absolute path. There are several different cookie files for different occasions and the appropriate one is selected.
$cookiepath = '/home/user123/public_html/curl/cookies/cookie123.txt';
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookiepath);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookiepath);
The php file gets called via direct access from a browser, via cronjob from cpanel and via command line as root user if some debugging is needed.
Now after moving the server and I saw some strange behaviour that curl sometimes won't use the cookies even though the cookie file was specified as above and existed exactly on that location. To be more exact the request made by curl simply didn't have any cookies.
Even doing 1 request where the response had a Set-Cookie
header the next request from curl still didn't have any cookies.
Now I'm suspecting there's something wrong with the file permissions since curl didn't even read the files.
ls -l cookie123.txt
-rw-r--r-- 1 cpanelhorde cpanelhorde 1182 Oct 24 17:53 cookie123.txt
are the permissions. Most of the time the owner and group are cpanelhorde
but sometimes it's root
.
Could there be some permission issues because I just downloaded the cookie files from the old server and uploaded them to the new one?