/ Published in: PHP

Function to create and record a cookie from an URL @params $url - the url to be opened @params $fileName - where the cookie will be stored @return nothing, since we know the cookie's path
Expand |
Embed | Plain Text
function openCookie($url,$fileName) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_COOKIEJAR, $fileName);//store the cookie information // some agent so the request won't get refused curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; Alexa Toolbar)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $content=curl_exec($ch); }
You need to login to post a comment.