I'm trying to login to a PunBB forum from a different page on the same domain using cURL.

When logging in, cURL gets executed and its initial response is the 'successful login' page of the forum. However no cookie got set thus when clicking any link in that forum, and I'm logged out.

After a bit of investigating my cookiejar file mentions the cookie needed to login. If I create this cookie and its value manually inb my browser, I am successfully logged in and all is well. So the cookie value stored is correct.

The line containing my cookie name/value in the cookiejar is however commented out.

first question: Why? second: How to prevent that behavior?

Here's my cookiejar:

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.example.com FALSE   /   FALSE   0   PHPSESSID   3d7oe6vt3blv3vs3ea94nljcs7
#HttpOnly_www.example.com   FALSE   /   FALSE   1340974408  forum_cookie_e19209 MnwyYWQ4OGViNDI2NjE5MWEwMGZiNGZkNDFmZDY5ZDZhYjM5OTA5NDVjfDEzNDA5NzQ0MDh8OTU0NTExOGZhNWNlNGY5OGMzZDk3MmE0NDlmMWRjNzM3ZjI1NzMxOA%3D%3D

And here's my curl call:

function forumLogin() {
    $loginFields = array('req_username' => $_REQUEST['username']
                        ,'req_password' => $_REQUEST['password']
                        ,'form_sent' => "1"
                    ); //and so on
    $login = getUrl('http://www.example.com/manager/forum/login.php', 'post', $loginFields);
   return $login;
}

function getUrl($url, $method='', $vars='') 
{
  $ch = curl_init();
  if ($method == 'post') {
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
  }
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
  curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies
Edit
Report