1

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.

SuperSpy
  • 1,324
  • 3
  • 13
  • 28
  • Maybe the account running PHP doesn't have the permission to write to the location you set for the cookie file... – CodeZombie Jan 26 '12 at 12:38

1 Answers1

2

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

Bogdan
  • 865
  • 6
  • 10
  • How can I get the cookie to be in my www directory? Is there an appache setting I should change? – SuperSpy Jan 26 '12 at 13:50
  • yes @SuperSpy, you could do something like ` $cookiefile = dirname(\_\_FILE\_\_)."/cookie.txt" ; curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookiefile);curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookiefile);` ( this will place the cookie in the same folder as the script is running, you can change accordingly for your desired path) – Bogdan Jan 26 '12 at 21:25