开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜