Copy code The code is as follows:
/*-----Save COOKIE-----*/
$url = 'www.xxx.com'; //url address
$post = "id=user&pwd=123456"; //POST data
$ch = curl_init($url); //Initialization
curl_setopt($ch,CURLOPT_HEADER,1); //Output the header file information as a data stream
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); //Return the obtained output text stream
curl_setopt($ ch,CURLOPT_POSTFIELDS,$post); //Send POST data
$content = curl_exec($ch); //Execute curl and assign value to $content
preg_match('/Set-Cookie:(.*); /iU',$content,$str); //Regular matching
$cookie = $str[1]; //Get COOKIE (SESSIONID)
curl_close($ch); //Close curl
/*-----Use COOKIE-----*/
curl_setopt($ch,CURLOPT_COOKIE,$cookie);
http://www.bkjia.com/PHPjc/728116.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/728116.htmlTechArticleCopy the code as follows: /*-----Save COOKIE-----*/ $url = 'www.xxx.com'; //url address $post = "id=user //POST data $ch = curl_init($url); //Initialize curl_setopt($ch,CURLOPT_HEA...