Is there anything in PHP that is equivalent to Cookiecontainer in ASP.
In ASP. NET, the access page can be completed by the following function, PostData is the data that requires the post-specified URL:
public string gethtml (string url, Cookiecontainer cookie, byte[] postdata);
How is it implemented in PHP? Is it possible to write like this?
function gethtml ($url, $tmpFile, $postData)
{
$ch = Curl_init ($url);
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_cookiejar, $tmpFile);
if ($postData!=null)
{
curl_setopt ($ch, Curlopt_post, 1);
}
$content =curl_exec ($ch);
return $content;
}
?>
are the following two sentences not few?
curl_setopt ($ch, Curlopt_cookiejar, $tmpFile);
curl_setopt ($ch, Curlopt_cookiefile, $tmpFile);
can I only pass temporary files? Is there any other way to improve it? O (∩_∩) o Thank you, ~~~~~~.
------Solution--------------------
Curlopt_cookiejar used to save cookies to a file when the connection is closed
Curlopt_cookiefile to send a cookie from a file when used to connect
Curlopt_cookie to send a COOKIE from a variable when used for connection
Whether you want to use it or not, depending on your application scenario
Save to file is the default action
You can use your own function to handle the curlopt_readfunction by setting the