Cul post method not creating cookie
In the below code i am trying to post the username and password but not able to create the cookie using post, if i do the same with get method it creates the cookie. 

		$BASEURL="http://localhost/openx/www/api/json/index.php/main/authenticate/";
		
		$POSTFIELDS='username="'.$username.'"&password="'.$password.'"';
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_FAILONERROR, 0);
		curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
		curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
		curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
		curl_setopt ($ch, CURLOPT_POST, 1);
		curl_setopt ($ch, CURLOPT_POSTFIELDS, $POSTFIELDS);
		curl_setopt($ch, CURLOPT_URL, $BASEURL);
		
		
		$returned = curl_exec($ch);

The curl_getinfo($ch) returns 200 OK http code, can anybody please advice what is wrong with the above code.

Thanks in advance.
 
Cul post method not creating cookie
===

In the below code i am trying to post the username and password but not able to create the cookie using post, if i do the same with get method it creates the cookie. 

		$BASEURL="http://localhost/openx/www/api/json/index.php/main/authenticate/";
		
		$POSTFIELDS='username="'.$username.'"&password="'.$password.'"';
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_FAILONERROR, 0);
		curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
		curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
		curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
		curl_setopt ($ch, CURLOPT_POST, 1);
		curl_setopt ($ch, CURLOPT_POSTFIELDS, $POSTFIELDS);
		curl_setopt($ch, CURLOPT_URL, $BASEURL);
		
		
		$returned = curl_exec($ch);

The curl_getinfo($ch) returns 200 OK http code, can anybody please advice what is wrong with the above code.

Thanks in advance.
 