You specify that you do not want the body from the response, and so you get none.
You also risk removing cookies by your call curl_setopt($ch, CURLOP_COOKIE, $cookie) if $cookie does not contain all the cookies that you previously had. And if all you want to do is use all those cookies, why not just use the same curl resource handle and do all that automatically.
$ch = curl_init();
# your first bunch of settings..
curl_setopt(...);
$r = curl_exec($ch);
# do stuff with the response
#no second curl_init() call, since you are continuing your existing session anyway
# setopt is fine if you do not want to use the same options as in the previous call
# just don't muck about with CURLOPT_COOKIE unless you want to remove/replace/add cookies
# to those allreay set
curl_setopt(...);
# yes, this second call really does contain the cookies set in the first call.
$r = curl_exec($ch);
But, all this also assumes that
1. You do not call curl_close until you are done with all your calls
2. You do not keep your resource handle $ch as a local non-static variable
So if you really want to use that wrapper function, you should either provide $ch as an argument
# once
$ch = curl_init();
$result = cURL($ch, /* as before... */);
# do stuff with result. no closing of the handle though
$result = cURL($ch, /* as before... */);
Or, you could use a static function variable
function cURL(...)
{
# this gets done once
static $ch = curl_init();
# rest of function body...
# no call to curl_close($ch), or the purpose is defeated
return $something;
}
However, unless you add a parameter that tells the function to actually do close the handle, there is no way of doing so.
All in all, I'd suggest not wrapping your setopt stuff in a function, but rather keep the options you want to use in an array. This way, it's easy to initialize the handle with your standard options.
# done once, somewhere
$curl_options = array(...);
# then, where you want to use it
$ch = curl_init();
curl_setopt_array($ch, $curl_options);
And if you want to wrap your curl handling in something, I'd make it a class. Then you can easily have an automated curl_init() call if the handle is null, reuse the same handle if it isn't, create a member function to close the handle etc.
Also, I'd recommend you change your error handling to
$r = curl_exec($ch);
if (curl_errno($ch) !== 0)
{
# error
}