Execute this code to check if the dir is writable:
PHP Code: 
<?php
if (is_writable(dirname(__FILE__)) echo "Good"
else echo "Bad";
?>
If it shows "good" then try this code and see if it works:

PHP Code: 
function getCookie($user$pass) {
        
$ch curl_init();
        
curl_setopt_array($ch, array(
            
CURLOPT_URL => 'http://blahblahblah.com/login.php',
            
CURLOPT_RETURNTRANSFER => true,
            
CURLOPT_COOKIEJAR => realpath('cookie.txt'),
            
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2',
            
CURLOPT_POST => true,
            
CURLOPT_POSTFIELDS => "user=$user&password=$pass"
        
));
        
curl_exec($ch);
        
curl_close($ch);
    } 
Get the realpath of the file by using realpath function - </span></span>realpath('cookie.txt')