I have two api pages, api1.php and api2.php. On 1 there is set an session and on 2 this session needs to be returned. Ofcourse there will be additional functions but my goal of this is to link those two api connections to one and eachother by using a session.
api1.php:
session_start();
$api_key = 'dfdsakdsfjdskfjdskfdsjfdfewfifjjsd';
$_SESSION['api_key'] = $api_key;
setcookie('api_key', $api_key);
api2.php:
session_start();
echo $_SESSION['api_key'];
echo $_COOKIE['api_key'];
test.php:
$url = 'http://example.com/api1.php';
$content1 = file_get_contents($url);
$url2 = 'http://example.com/api2.php';
$content2 = file_get_contents($url2);
echo $content2;
As you may have noticed, i'm visiting the page test.php to obtain a result. But no result is being returned. Can somebody tell me why this is not working and what may be an additional way of making all of this happen?
(Notice: the example.com are both the same site (mine))