Hi all,

Hope someone has done this before, I am trying to communicate to an external webserver using cURL. For some reason it seems to drop my session after the authentication page has let me in. There are more pages to query but this is where I am stuck.

At the moment the script is configured to get a new cURL session using the same cookie file, but I have also tried it using a single cURL session without much success. I know the cookie works because the login page does nothing at all if I do not specify it.

Does anyone know if there is some option that I may be missing.

PHP Code:
<?php

    
function createConnection()
    {
        static 
$cookie false;
        if (!
$cookie) {$cookie session_name() . '=' time();}

        
$session curl_init();

        
curl_setopt($sessionCURLOPT_HEADER0); 
        
curl_setopt($sessionCURLOPT_COOKIESESSIONtrue); 
        
curl_setopt($sessionCURLOPT_COOKIEFILE'cookiefile'); 
        
curl_setopt($sessionCURLOPT_COOKIEJAR'cookiefile'); 
        
curl_setopt($sessionCURLOPT_COOKIE$cookie); 
        
curl_setopt($sessionCURLOPT_FOLLOWLOCATION1); 

        
curl_setopt($sessionCURLOPT_SSLCERT'xxxxxxxx.p12'); 
        
curl_setopt($sessionCURLOPT_SSLKEYPASSWD'xxxxxxxx'); 
        
curl_setopt($sessionCURLOPT_SSLCERTTYPE'P12'); 

        
curl_setopt($sessionCURLOPT_RETURNTRANSFERfalse);

//        curl_setopt($session, CURLOPT_POST, false);
//        curl_setopt($session, CURLOPT_POSTFIELDS, '');

        
curl_setopt($sessionCURLOPT_REFERER'https://xxxxxxxx/');
        return 
$session;
    }

    function 
destroyConnection($session)
    {
        
curl_close($session);
    }

    
//LOGGING IN

    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/');
    
curl_exec($session);
    
destroyConnection($session);

    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/xxxxxxxx/SignOn');
    
curl_setopt($sessionCURLOPT_POSTtrue);
    
curl_setopt($sessionCURLOPT_POSTFIELDS'lastpage=login&buttonClicked=proceed');
    
curl_exec($session);
    
destroyConnection($session);

    
//DOWNLOAD ALL FRAMESET PAGES

    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/xxxxxxxx/xxxxxxxxlogin.html');
    
curl_exec($session);
    
destroyConnection($session);

    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/xxxxxxxx/loggedin.jsp');
    
curl_exec($session);
    
destroyConnection($session);

    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/xxxxxxxx/legalframe.html');
    
curl_exec($session);
    
destroyConnection($session);


    
$session createConnection();
    
curl_setopt($sessionCURLOPT_URL'https://xxxxxxxx/xxxxxxxx/xxxxxxxx/paymentsxxxxxxxx.jsp');
    
curl_exec($session);
    
destroyConnection($session);

Thanks!!