$snoopy->agent="Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0";
$url='http://www.jb51.net/test/Login.php';//URL address for login data submission
set_time_limit(0);
$cookie_file=tempnam('./tmp','cookie');//The tmp directory needs to be created first
$ch=curl_init();
$login_url='http://www.jb51.net/PLogin.do';
$curlPost="email=login account&password=login password";
curl_setopt($ch,CURLOPT_URL,$login_url);
//When enabled, the header file information will be output as a data stream
curl_setopt($ch,CURLOPT_HEADER,0); //Set whether to output page content
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1); //Set the request sending method, post or get, CURLOPT_POST or CURLOPT_GET
curl_setopt($ch,CURLOPT_POSTFIELDS,$curlPost);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file); //Save cookie
curl_exec($ch);
curl_close($ch);
$ch=curl_init();
$login_url2="http://www.jb51.net/";
curl_setopt($ch,CURLOPT_URL,$login_url2);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file); //Read cookie
curl_exec($ch);
curl_close($ch);
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/971920.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/971920.htmlTechArticleAnalysis of the implementation method of php simulated login This article mainly introduces the implementation method of php simulated login, and analyzes snoopy with examples The two implementation methods with curl have certain reference value and require...