For my project purpose, i need to login to my facebook account remotely and retrieve some information from there. For the login purpose, i am using cURL library of PHP. On e
To use cookies with curl you'll need to specify a "cookie jar", which is where the cookies should be stored and loaded from. You can do this using the CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR options. Something like this should do it:
curl_setopt($ch, CURLOPT_COOKIEJAR, 'facebook_cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'facebook_cookies.txt');
Check out http://php.net/curl_setopt for more information.
As an aside, you can also pass $post_fields as an array to CURLOPT_POSTFIELDS, so you don't actually have to generate the query string yourself. If you want to do that, there is also a http_build_query() function that does this. This is unrelated to the issue you posted though.