How can I use current site cookies to login to another site and then redirect to another page ?
I have multiple websites which uses the same external Authenticator.I am trying to make a CURL request from one site to get data from the other site . But I have authentication issue while making the CURL request to other site.
In order to login to another site I need to click on login URL but credentials need not be entered again.
So My actual requirement is :
Use Cookies from current site.
Make a CURL request to another site login URL and login to that site using Cookies from current site.
Make a CURL request to another URL where you can obtain the required data.
I can obtain data from the other site if I am logged into that site in the browser.
My Current Code is as follows:
$agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)";
$loginURL = $url . 'saml_login';
$cleanedURL = $url . 'anotherurl/list';
$curl = curl_init();
//Before making CURl request to $cleanedURL I need to make request to $loginURL(which has a redirect)
curl_setopt($curl, CURLOPT_URL, $cleanedURL);
curl_setopt($curl, CURLOPT_USERAGENT, $agent);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Cookie: ' . $_SERVER['HTTP_COOKIE']));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE);
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
$response = curl_exec($curl);
var_dump($response);
All the examples I came across used either used credentials in the header or cookies file which is already exported.
Can any one help me to suggest it.