note 128774 added to function.curl-setopt
| From: | alexchexes at gmail dot com | Date: | Wed, 02 Aug 2023 14:06:56 +0000 |
| Subject: | note 128774 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220734@lists.php.net to get a copy of this message | ||
If you want cURL to successfully write cookies to a file specified with CURLOPT_COOKIEJAR, ensure
that cURL has the necessary permissions to modify the file if it already exists.
I spent nearly a day trying to understand why cURL wasn't saving cookies to an existing file,
even though I could easily modify the exact same file using file_put_contents(). Moreover, cURL
itself could create the same file and save cookies, but only if it didn't previously exist.
Ultimately, the issue was related to file ownership. I was working within WSL2, inside a symlinked
Windows directory. The [automount]"metadata" in wsl.conf was not set, causing every file
created from PHP to have the default owner, which differed from the user running PHP.
Once I configured wsl.conf and then changed the ownership of the entire directory to match the user
running PHP, cookies were successfully written to any file without any issues.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 193.138.218.226)
----
Manual Page -- https://php.net/manual/en/function.curl-setopt.php
Edit -- https://main.php.net/note/edit/128774
Del: integrated -- https://main.php.net/note/delete/128774/integrated
Del: useless -- https://main.php.net/note/delete/128774/useless
Del: bad code -- https://main.php.net/note/delete/128774/bad+code
Del: spam -- https://main.php.net/note/delete/128774/spam
Del: non-english -- https://main.php.net/note/delete/128774/non-english
Del: in docs -- https://main.php.net/note/delete/128774/in+docs
Del: other reasons-- https://main.php.net/note/delete/128774
Reject -- https://main.php.net/note/reject/128774
Search -- https://main.php.net/manage/user-notes.php