note 85747 modified in function.curl-setopt by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 17:18:41 +0000 |
| Subject: | note 85747 modified in function.curl-setopt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154965@lists.php.net to get a copy of this message | ||
Some of you may noticed that curl is not transferring cookies between sequent calls to a host. This
is because you must activate curl`s "cookie parser". That is achieved using an external
file like this:
<?php
curl_setopt(CURLOPT_FILE, '/tmp/cookies_file');
?>
If you don`t need to read any cookies but you still want the "cookie parser" use the same
code but with dummy file with no data like '/dev/null', that way curl is storing cookies
internaly per curl_handle:
<?php
curl_setopt(CURLOPT_FILE, '/dev/null');
?>
[EDIT BY danbrown AT php DOT net: In a note dated 26-SEP-08, (adamplumb AT gmail DOT com) offered
the following addendum:
[It] should really be CURLOPT_COOKIEFILE. I was bitten by this issue myself with code that
previously worked for logging into a website and posting a form. However, at some point the code
just stopped working, and I eventually found that I needed to set this option to /dev/null for it to
work.
]
--was--
Some of you may noticed that curl is not transferring cookies between sequent calls to a host. This
is because you must activate curl`s "cookie parser". That is achieved using an external
file like this:
<?php
curl_setopt(CURLOPT_FILE, '/tmp/cookies_file');
?>
If you don`t need to read any cookies but you still want the "cookie parser" use the same
code but with dummy file with no data like '/dev/null', that way curl is storing cookies
internaly per curl_handle:
<?php
curl_setopt(CURLOPT_FILE, '/dev/null');
?>
http://php.net/manual/en/function.curl-setopt.php