Home  >  Article  >  Backend Development  >  PHP method to add cookies to forge login and capture data through curl_php tips

PHP method to add cookies to forge login and capture data through curl_php tips

WBOY
WBOYOriginal
2016-05-16 19:54:541452browse

The example in this article describes how PHP adds cookies to fake login and capture data through curl. Share it with everyone for your reference, the details are as follows:

Some web pages must be logged in to see. At this time, if you want to capture the information, you must pass the cookie value in the header to obtain it

1. First log in to the website, open firebug and you will see the corresponding cookies. Copy these cookies and you can use them

2,

<&#63;php
header("Content-type:text/html;Charset=utf8");
$ch =curl_init();
curl_setopt($ch,CURLOPT_URL,'http://www.babytree.com/user/picjournal.php');
$header = array();
//curl_setopt($ch,CURLOPT_POST,true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_COOKIE,'B=115.100.62.7.1401937092035530; bdshare_firstime=1401937092199; __myutma=122328856.1548793539.1401937093.1408503164.1408694138.69;');
$content = curl_exec($ch);
echo "<pre class="brush:php;toolbar:false">";print_r(curl_error($ch));echo "
"; echo "
";print_r(curl_getinfo($ch));echo "
"; echo "
";print_r($header);echo "
"; echo "
",$content;

Readers who are interested in more PHP-related content can check out the special topics on this site: "Summary of php curl usage", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "Introduction to PHP basic syntax tutorial", "Summary of PHP operating office document skills (including word, excel, access, ppt)" , "php date and time usage summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", " php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn