Hello a new site I did is due for launch tomorrow and I have one thing left to fix which doesn't work, hence the urgency. I'll pay something if the price is right to whoever can help me fix this by tonight or tomorrow morning.

It's about CURL. I am trying to log in a password protected area and then perform an action but I can't seem to keep the login session alive between the two curl actions.
I log in ok but when I go to execute $ch3 curl is already logged out.
I thought I solved the issue with the cookie options (I even created a dummy txt file with that name and chmodded it to 777) but it won't stay logged in.

I've blanked out username and password from my code.

Thanks to anyone who will take the time.

PHP Code:
       // MAMBO admin login 
       $url2 = 'http://www.chaindlk.com/content/administrator/index.php'; 
       $urlstring2 = 'usrname=XXXXXX&pass=XXXXXX&submit=Login'; 
       $ch2 = curl_init(); 
       curl_setopt($ch2, CURLOPT_URL,$url2); 
       curl_setopt($ch2, CURLOPT_HEADER, 0); 
       curl_setopt($ch2, CURLOPT_POST, 1); 
       curl_setopt($ch2, CURLOPT_POSTFIELDS, $urlstring2); 
       curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 0); 
       curl_setopt($ch2, CURLOPT_REFERER, 'http://www.chaindlk.com/content/administrator/index.php'); 
       curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); 
       curl_setopt($ch2, CURLOPT_COOKIEJAR, 'registration.txt'); 
       $data2 = curl_exec($ch2); 
 if ( substr_count(strtolower($data2), strtolower("<script>document.location.href='index2.php';</script>")) >= 1 ) 
       echo '<script>alert("MOS admin login DONE");</script>'; 
     if ( substr_count(strtolower($data2), strtolower("<script>document.location.href='index2.php';</script>")) >= 1 ) { 
           // COMMUNITY BUILDER user tables synchronization 
         $url3 = 'http://www.chaindlk.com/content/administrator/index2.php?option=com_comprofiler&task=syncUsers'; 
           $urlstring3 = 'option=com_comprofiler&task=syncUsers'; 
           $ch3 = curl_init(); 
           curl_setopt($ch3, CURLOPT_URL,$url3); 
           curl_setopt($ch3, CURLOPT_HEADER, 0); 
           curl_setopt($ch3, CURLOPT_POST, 1); 
           curl_setopt($ch3, CURLOPT_POSTFIELDS, $urlstring3); 
           curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, 0); 
         curl_setopt($ch3, CURLOPT_REFERER, 'http://www.chaindlk.com/content/administrator/index2.php?option=com_comprofiler&task=tools'); 
           curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1); 
           curl_setopt($ch3, CURLOPT_COOKIEFILE, 'registration.txt'); 
           $data3 = curl_exec($ch3); 
   if ( substr_count(strtolower($data3), strtolower(&quot;now in sync&quot;)) >= 1 ) 
       echo '<script>alert("sync DONE");</script>'; 
PS I never get to the second alert (sync DONE)...
PPS as you might get from the example to make sure I am actually logged in I check to see if the log in page directs me to the login area (which is index2.php), and I looked at the code, it does it with a js document.location, so that is NOT the issue...