PHP and cURL cookies

前端 未结 3 1318
小蘑菇
小蘑菇 2020-12-20 07:37

I am trying to setup a php page which uses cURL to hit a third party server to log them in. Right now my code does successfully log in to the third party server, but since c

3条回答
  •  Happy的楠姐
    2020-12-20 07:58

    You can set the cookie in the user's browser without redirecting him to the server. what you need to do is get the user to hit your php page with the curl code in it. then you can take his post data and send this data to the server. But dont let the server redirct you. Set the option as CURLOPT_FOLLOWLOCATION as false and set CURLOPT_HEADER as true Now grab the header and extract the cookie and location headers and then pass those as headers to the client browser like header("Location: ...) and header("Set-Cookie: ....). you can also send other headers by extracting them too. the following [post] html page not getting cookies through libcurl has a similar situation

提交回复
热议问题