php - 将 cookie 添加到 curl 的 cookiejar

标签 php cookies curl

我希望能够将从 javascript 设置的 cookie 添加到 cookie jar 中。有没有用于此的 PHP 函数?或者我应该只使用 fopen 打开 cookie jar 并劫持它?

最佳答案

正如其他人所建议的,为了添加 cookie,您必须将 cookie 添加到 cookie jar curl 属性中提到的 cookieFile。

file_put_contents($cookie, ".ebay.com   TRUE    /   FALSE   0   lucky9  ".$lucky9, FILE_APPEND | LOCK_EX,null);

上面是我将 cookie 插入到我的 cookieFile 中所做的事情。

cookieFile 在 7 个制表符分隔的属性中包含一个 cookie:

domain - The domain that created AND that can read the variable. 
flag - A TRUE/FALSE value indicating if all machines within a given domain can access 
 the variable. This value is set automatically by the browser, depending on the value    you set 
 for domain. 
 path - The path within the domain that the variable is valid for. 
 secure - A TRUE/FALSE value indicating if a secure connection with the domain is needed      to access the variable. 
 expiration - The UNIX time that the variable will expire on. UNIX time is defined as   the number of seconds since Jan 1, 1970 00:00:00 GMT. 
 name - The name of the variable. 
 value - The value of the variable.

取自here.

关于php - 将 cookie 添加到 curl 的 cookiejar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5974342/

相关文章:

tomcat - 防止跟踪 cookie(例如 google analytics)到达应用后端

c - 在 C 中使用 cURL 使用 HTTP 代理

php - 实际上有可能使用.send()发送二进制XHR请求吗?

PHP 加密数据,Bash 解密

php - 时间戳自动更新不适用于 ON DUPLICATE KEY UPDATE (PDO)

php - 使用 PHP 和 cURL 连接到 Insightly API

curl - 如何使用带有 curl 的 GitHub API v3 创建和发布版本?

php - 操纵 Joomla 内容

java - 如何在java中发出HTTP post请求登录时获取cookie并发布它

javascript - (JavaScript) 未创建 Cookie