开发者

How to get session id and do login web form with session id curl?

开发者 https://www.devze.com 2023-02-06 14:52 出处:网络
How to 开发者_如何学编程get session idand do login web form with session id curl?Set CURLOPT_RETURNTRANSFER, store the return value of curl_exec() in a variable, use string functions and/or regular ex

How to 开发者_如何学编程get session id and do login web form with session id curl?


Set CURLOPT_RETURNTRANSFER, store the return value of curl_exec() in a variable, use string functions and/or regular expressions to extract the session id from the page.

If the session ID is just in a header (e.g. Set-cookie), use curl_setopt() to set CURLOPT_HEADER so headers are included in the output.

If you want to use the session id later to submit a form, set CURLOPT_POST to true and CURLOPT_POSTFIELDS to an associative array containing your POST data.

Useful php documentation links:

  • http://php.net/curl_exec
  • http://php.net/curl_setopt
  • http://php.net/preg_match
0

精彩评论

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

关注公众号