Curl setting cookies

Discussion in 'PHP' started by patlatyj, Feb 8, 2008.

  1. #1
    Hello! I'm logging into some site using curl, well, actually the code is
    $url='http://*****;
    $host=parse_url($url);
    $host=str_replace('www.','',$host);
    
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'E:\xampp\htdocs\cookie\\'.$host);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, '*{login information}**');
    
    echo curl_exec($ch); 
    
    curl_close($ch);
    Code (markup):
    I can see that I've logged in and can move within current curl session and domain, staying in, however, there is no file like E:\xampp\htdocs\cookie\\'.$host, that's why when I try to load that site after a while, I have to login again.. I'd like to make a script that loggs in, than skips this operation if the cookie was set before... How could I do that, why is no file created? TIA
     
    patlatyj, Feb 8, 2008 IP