且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何让Curl使用与PHP浏览器相同的cookie

更新时间:2023-02-22 10:18:55

您不能。

如果您收到请求,您需要解析输出和替换所有链接,以便它们通过您的服务器。

If you curl the request, you will need to parse the output, and replace all links so they go thru your server.

  www.yourdomain.com/f?=www.someotherdomain.com/realpage

这样做的唯一方法是在curl请求中使用持久性cookies。 CURL可以保留Cookie本身。将会话ID分配给cookie文件(curl),以便后续请求获得相同的Cookie。当用户点击某个链接时,您需要再次调整该请求。

The only way this would work is if you use persistent cookies in your curl request. CURL can keep cookies itself. Assign a session ID to the cookie file (in curl) so subsequent requests get the same cookies. When a user clicks a link, you will need to curl the request again.

这是一个安全问题,允许site1为site2设置cookie。想象一下,如果你可以在浏览器中设置cookie的paypal和欺骗用户认为他们已经记录int或一些其他恶意动作。

It is a security issue to allow site1 to set cookies for site2. Imagine if you could set cookies in the browser for paypal and trick the user into thinking they had logged int or some other malicious action.