Is there anything in PHP that's like Cookiecontainer in ASP.

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.