curl & session

Status
Niet open voor verdere reacties.

kenikavanbis

Terugkerende gebruiker
Lid geworden
22 mei 2007
Berichten
2.196
Telkens ik een pagina opgeroepen heb verandert de sessievar ook al is die altijd het zelfde
PHP:
   $ch = curl_init($host.$url."?".$getstr);
    curl_setopt($ch,    CURLOPT_COOKIE, ("JSESSIONID=".$asoarr['ses_id'].";"));
    curl_setopt($ch,    CURLOPT_AUTOREFERER,         true);
    curl_setopt($ch,    CURLOPT_COOKIESESSION,         true);
    curl_setopt($ch,    CURLOPT_FAILONERROR,         false);
    curl_setopt($ch,    CURLOPT_FOLLOWLOCATION,        true);
    //curl_setopt($ch,    CURLOPT_FRESH_CONNECT,         true);
    curl_setopt($ch,    CURLOPT_HEADER,             true);
    //curl_setopt($ch,    CURLOPT_POST,                 false);
    curl_setopt($ch,    CURLOPT_RETURNTRANSFER,        true);
    curl_setopt($ch,    CURLOPT_CONNECTTIMEOUT,     100);
    $content = curl_exec($ch);
 
Ik heb zelf ook wat gespeeld met curl, de eerste request moet met
Code:
curl_setopt($ch>curl, CURLOPT_HEADER, true); // output the header the first time (for fetching the cookies)
Daarna moet je de cookies uit het resultaat parsen, zodat die de keer erop meegegeven kunnen worden

Code:
    $result = curl_exec($ch);
    if (preg_match_all('|Set-Cookie: (.*);|U', $response, $results)) {
      $cookies = implode(';', $results[1]);
      curl_setopt($ch, CURLOPT_COOKIE, $cookies);
    }
    curl_setopt($ch, CURLOPT_HEADER, false);
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan