Why is curl storing my cookie in c:\

Go To StackoverFlow.com

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?

2012-04-04 16:37
by KiloJKilo
You are escaping your slashes right - PeeHaa 2012-04-04 16:38


0

Use

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

I hope it helps

Thanks :)

2012-04-04 16:46
by Baba
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 2012-04-04 17:10
use vardump(fileexists('c:\server\docs\cookie.txt')) and tell me what you hav - Baba 2012-04-04 17:47
bool(false) - is that what you want - KiloJKilo 2012-04-04 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 pat - Baba 2012-04-04 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 2012-04-04 18:33
There is no script here ??? - Baba 2012-04-04 18:35
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 2012-04-04 18:43
put it at pastebin or something .. send the link i"ll help you out i'll help you out .. - Baba 2012-04-04 18:46
http://pastebin.com/NX9jwVE - KiloJKilo 2012-04-04 18:57
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 value - Baba 2012-04-04 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 2012-04-04 19:26
May be you don't have permission in that folder ... try a diffrent folder with no spaces or use getcwdBaba 2012-04-04 19:36
I'm sorry, I do not know how to use getcwd. I am on windows th - KiloJKilo 2012-04-04 19:38
http://php.net/manual/en/function.getcwd.php echo getcwd() . "\n";Baba 2012-04-04 19:42
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 2012-04-04 19:50
Thanks .. hope i was able to help @KiloJKil - Baba 2012-04-04 22:15


0

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

2012-04-04 16:41
by SolidSnake
The script still breaks when I escape the slashes. But the cookie is still written to the directory I want - KiloJKilo 2012-04-04 16:51
Ads