Curl Redirect

$redirect_url = redirects to another site that verifies that a user has a cookie. If they are cookied than it redirects back to the original site.

This is my code:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $redirect_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($ch);

curl_close($ch);

This does not seem to work. When I print $output than it shows the redirect site if they haven’t been cookied.

BTW this works but causes an infinite loop. That is why I am trying to replace this with the curl function.

<iframe src="'. $redirect_url . '" height="0px" width="0px" style="visibility:hidden;"></iframe>

I see no cookie settings being set there…

The problem was that the $redirect_url (another site) was looking for a cookie with the user id. If I viewed the url by pasting into browser it would see the cookie. I do not know what the user id is because it was set by the other site so that option of sending the cookie would not be possible.

I just created a script that would set a cookie with a 10 second expiration and just verify that it is not there or empty to prevent infinite loop. No curl function is necessary.