0

I'm setting the curl cookiejar option with the following:

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

this puts the file in c:\

I try to use an absolute path (c:\server\docs) and the script breaks. Even so, the cookie does get written to that path. Odd.

Is there another way I'm supposed to define the path to my webserver?

KiloJKilo
  • 465
  • 1
  • 6
  • 16

2 Answers2

0

I guess you need to change it to "c:\\server\\docs\\"

Desolator
  • 22,411
  • 20
  • 73
  • 96
  • The script still breaks when I escape the slashes. But the cookie is still written to the directory I want. – KiloJKilo Apr 04 '12 at 16:51
0

Use

define("SITE_PATH",'c:\server\docs');
curl_setopt($ch, CURLOPT_COOKIEFILE, SITE_PATH . "/cookie.txt");

I hope it helps

Thanks :)

Baba
  • 94,024
  • 28
  • 166
  • 217
  • This doesn't seem to work either. Curious, why do you use a / in front of your cookie.txt? I've tried with /, and // and \\, and \ and nothing there and none of it works. – KiloJKilo Apr 04 '12 at 17:10
  • use var_dump(file_exists('c:\server\docs\cookie.txt')) and tell me what you have – Baba Apr 04 '12 at 17:47
  • bool(false) - is that what you want? – KiloJKilo Apr 04 '12 at 18:13
  • Yes that is what i expected .... your script is not working because the files does not exist... can you get the real file path – Baba Apr 04 '12 at 18:18
  • holy crap. I had to make a correction to the path and now I get bool(true). However, the script still does not log me in. – KiloJKilo Apr 04 '12 at 18:33
  • I posted the script earlier and got ridiculed so I'm not going to post it again. If I leave my cookie set to just plain "cookie.txt" my script logs me in. If I try to change it at all, it doesn't log me in. If you want to see the script it'll have to happen off stack overflow. – KiloJKilo Apr 04 '12 at 18:43
  • put it at pastebin or something .. send the link i"ll help you out i'll help you out ... – Baba Apr 04 '12 at 18:46
  • Now i understand what you are trying to .. you need to first get the cookies and right it to `cookies.txt` just like the way you have done for `__EVENTVALIDATION` see http://stackoverflow.com/questions/895786/how-to-get-the-cookies-from-a-php-curl-into-a-variable on getting cookie values – Baba Apr 04 '12 at 19:18
  • yeah, and that happens, as long as i define the location of cookies.txt as just cookies.txt. i wanted to change it because it was storing it on c:\. i cannot figure out how to store it in \tmp. – KiloJKilo Apr 04 '12 at 19:26
  • May be you don't have permission in that folder ... try a diffrent folder with no spaces or use `getcwd` – Baba Apr 04 '12 at 19:36
  • I'm sorry, I do not know how to use getcwd. I am on windows tho – KiloJKilo Apr 04 '12 at 19:38
  • That doesn't display any information. If it's creating the cookie.txt in whatever location I designate, doesn't that indicate it has at least some permission? I don't get why it writes the cookie but cuases the script to break. – KiloJKilo Apr 04 '12 at 19:50
  • Thanks .. hope i was able to help @KiloJKilo – Baba Apr 04 '12 at 22:15