Default location for CURLOPT_COOKIEFILE file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Default location for CURLOPT_COOKIEFILE file

Post by anjanesh »

Code: Select all

curl_setopt ($handle, CURLOPT_COOKIEFILE, "cook.txt");
Anyone know where does cook.txt get created ? Which is the default location for cook.txt ?
I dont want to insert an absolute path.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

search. your. computer. :roll:
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Ok - I've set it to a specific location and I can view it - but thats because I know the location of the file.

Code: Select all

curl_setopt ($handle, CURLOPT_COOKIEFILE, "D:/xxx/cook.txt");
curl_setopt ($handle, CURLOPT_COOKIEJAR,  "D:/xxx/cook.txt");
How do I set a relative path ? This code will only work if there exists a directory D:\xxx and I got permission to write to that directory. When I upload to a linux server (possibly shared) then I wouldnt know the full path.
yum-jelly
Forum Commoner
Posts: 98
Joined: Sat Oct 29, 2005 9:16 pm

Post by yum-jelly »

any path in any function call in PHP default to where the script is run from (directory). So if your running the script from C:/path/to script.php, then the cookie file will be at C:/path/cookie_file_name.extension. If you want to put it in it own directory then you could do this...

Code: Select all

$cookies = './cookies/';

curl_setopt ( $handle, CURLOPT_COOKIEFILE, $cookies . 'cookie.txt' );
Then PHP will store the cookie file in.... (as long as you have a directory called cookies in the same directory where the script is!)

C:/path/cookies/

If you just want to store where the script is then you could use...

Code: Select all

$cookies = './cookies.txt';

curl_setopt ( $handle, CURLOPT_COOKIEFILE, $cookies );

yj!
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

any path in any function call in PHP default to where the script is run from (directory). So if your running the script from C:/path/to script.php, then the cookie file will be at C:/path/cookie_file_name.extension.
It doesnt seem so.
My Apache is in C:\Program Files\Apache Group\Apache 2\ and my htdocs is in D:\
When not giving the absolute path, cookie.txt is getting stored in C:\Program Files\Apache Group\Apache 2\ and not the D:\htdocs\xxx which is where my curl script is running.
Post Reply