开发者

How do I inject cookies when using a cookie jar in CURL?

开发者 https://www.devze.com 2023-01-13 21:49 出处:网络
I am using php curl and i am using the cookie jar for a multi-step crawl. I need the dynamically generated cookies from the server.

I am using php curl and i am using the cookie jar for a multi-step crawl. I need the dynamically generated cookies from the server.

But at one step some cookies are generated using javascript. Since curl does开发者_C百科n't run javascript I need to inject cookies to curl at this point.

The only way I can see doing this is manually reading the cookie file, and setting all the cookies plus the ones I want using curl_Setopt and CURLOPT_COOKIE.

Is there a way to inject cookies without loosing the ones already there?


I found if you use the cookie jar, and curl_setopt wit CURLOPT_COOKIE it doesn't overwrite the cookies it loaded from the file, it just appends them.

So the answer is to use CURLOPT_COOKIE.

Thanks Byron!

0

精彩评论

暂无评论...
验证码 换一张
取 消