问题
EDIT: How can I change the relative path to 'relative-to-this-file' mode? Like on my host...
I've got a cURL PHP
script which works. It gets my schedule from my school site. Though there is one strange thing: On my webhost it creates the cookie.txt and on my localhost it doesn't.
- Why doesn't cURL create a cookie on my localhost? Something with relative paths and wampserver? Maybe some settings on wamp?
I am using:
- WampServer
- Windows 7
cURL does create a cookie if I use: '/cookie.txt' but ofcourse it creates it in my c:/. And that is obviously not where I want it to be. Also I want to prevent using full paths.
回答1:
be sure you have these two options in the curl setup phase
$cookiefile = dirname(__FILE__)."/cookie.txt" ;
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookiefile);
they will create a cookie in the folder your script resides in
EDIT : added option to set the cookie in the same dir as the script is running in
来源:https://stackoverflow.com/questions/9018155/how-can-i-make-curl-set-a-cookie-relative-to-the-script