$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,35);
curl_setopt($curl_handle,CURLOPT_TIMEOUT,50);
curl_setopt($curl_handle,CURLOPT_FOLLOWLOCATION,1);
$cookie_file = "/tmp/cookies/".$file;
if(!is_file($cookie_file)){
$fd = fopen($cookie_file,"w");
if(!$fd) throw new Exception("can not create cookie file");
fclose($fd);
}
curl_setopt($curl_handle,CURLOPT_COOKIEFILE,$cookie_file);
curl_setopt($curl_handle,CURLOPT_COOKIEJAR,$cookie_file);