Code: Select all
https://my.example.com/authentication.php?user=Username&pass=PW&destination=https://someurl.example.com/SomethingCode: Select all
header("Location: https://my.example.com/authentication.p ... /Something");If I attempt to call this URL in my code, it doesn't work. There are multiple redirects that occur if I type it in the address bar, and I've used FOLLOWLOCATION, 1, but that doesn't seem to help.
The latest iteration of code attempts to request the page that sets the cookies, and then make subsequent requests that include the cookies, but it still winds up kicking me back to the first page.
Code: Select all
$cookie_jar = tempnam('/tmp','cookie');
$c = curl_init('https://my.example.com/authentication.php?user=Username&pass=PW');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
$page = curl_exec($c);
curl_close($c);
$c = curl_init('https://someurl.example.com/Something');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, 'field=value');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
$page = curl_exec($c);
curl_close($c);