我希望能够将从 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/