如何在cURL请求中发送cookie?

I am trying to use my Wordpress site to send a cURL request to a remote server, but when I try to do it, I get the error

Cookies are not supported by your browser

I have given 777 permissions to the cookiejar file. I have tried changing the testcookie value within the post field to be 0, with no luck. I read on another stackoverflow answer that if I include dirname(__FILE__) within the curlopt_cookiejar set function, that might fix the problem but it hasnt. Anyway here's the code to my cURL post.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $loginUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "log=$email&pwd=$password&wp-submit=Log%20In&redirect_to=$loginUrl&testcookie=1"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIESESSION, false );
    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) .  '/uniquefilename' );
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt' );

hopefully this question isnt vague, im still a noob.

So, I figured out what the problem was. I removed the line curl_setopt($ch, CURLOPT_COOKIESESSION, false ); and changed the value of the CURLOPT_POST to true.