Cookie php curl - false [英] cookies php curl - false
问题描述
为什么当我抓取一个cookie并将其存储到一个文件中时,每行都是FALSE / FALSE?我尝试了各种不同的方式,并仍然结束了同样的事情。我缺少什么?为了澄清,你加载一个网址,它设置一个cookie,并反弹到另一个网址,然后读取该cookie。但我甚至不能得到正确设置的cookie。这是我的代码:
Why is it that when I grab a cookie and store it to a file, every line is FALSE/FALSE? I've tried various different ways and still end up with the same thing. What am I missing? And for a clarification, you load one url, it sets a cookie and bounces to another url where that cookie is then read. But I can't even get the cookie to set properly. Here's my code:
$cookie_file_path = 'cookie.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url3);
curl_setopt($ch, CURLOPT_HEADER ,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$content = curl_exec($ch);
curl_close( $ch );
echo $content;
编辑:
所以我的问题是这个帖子 - 通过接收FALSE / FALSE
So my question is for this post - by receiving FALSE /FALSE - does that mean the cookie isn't set properly?
推荐答案
请参阅 http://curl.haxx.se/mail/archive-2005-03/0099.html 有关格式说明 cookie.txt
文件。列为:
See http://curl.haxx.se/mail/archive-2005-03/0099.html for a description of the format of the cookie.txt
file. The columns are:
- domain
- tailmatch
- / li>
- domain
- tailmatch
- path
- secure
- expires
- name
- value
tailmatch
和 secure
都是布尔值,因此它们 TRUE
或 FALSE
。所以,如果你看到:
tailmatch
and secure
are both booleans, so they're either TRUE
or FALSE
. So if you see:
www.domain.com FALSE / FALSE ...
这意味着:
-
tailmatch = FALSE
-
path = /
表示Cookie适用于域中的所有路径 -
secure = FALSE
表示Cookie不需要SSL
tailmatch = FALSE
path = /
means the cookie applies to all paths in the domainsecure = FALSE
means the cookie doesn't require SSL
tailmatch
domain
将会是 .domain.com
,而不是像 www.domain.com
。
tailmatch
is true when the cookie applies to all subdomains of a domain, rather than a specific hostname; the domain
would then be .domain.com
rather than something like www.domain.com
.
这篇关于Cookie php curl - false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!