curl-and-php
Re: set cookie
Date: Wed, 20 Jan 2010 20:09:39 +0000
Please refer to manual:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE
2010/1/20 Mindaugas <manxp_at_freemail.lt>
> I need to setup cookie before sending further requests, and my code looks
> like:
>
>
>
>
>
> $cookie="cookie.txt";
>
>
>
> $ch=curl_init();
>
> curl_setopt($ch, CURLOPT_URL, $url]);
>
> curl_setopt($ch, CURLOPT_USERAGENT, $agent);
>
> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
>
> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
>
> curl_setopt($ch, CURLOPT_COOKIE, "some_text");
>
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
>
> $post=curl_exec($ch);
>
> curl_close($ch);
>
>
>
>
>
> When I run this code, file “cookie.txt” remains empty. Isn’t curl supposed
> to write “some_text” to cookie.txt file when code is launched? Or is my code
> wrong?
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-01-20