Posted By

rabc on 08/07/10


curl php cookie open

Versions (?)

Open Cookie

 / 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

  1. function openCookie($url,$fileName) {
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, $url);
  4. curl_setopt ($ch, CURLOPT_COOKIEJAR, $fileName);//store the cookie information
  5. // some agent so the request won't get refused
  6. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; Alexa Toolbar)");
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  9. $content=curl_exec($ch);
  10. }

Report this snippet  

You need to login to post a comment.