I have 2 .php files
The first php creates a session:
<?php
session_start();
$_SESSION['ID'] = '1';
$_SESSION['NAME'] = 'ALIAS';
$_SESSION['TIME'] = time();
print_r($_SESSION);
The second file has the same session and if it is called from the same browser using the GET method should return the values of the session:
<?php
session_start();
if($_SERVER['REQUEST_METHOD'] == "GET"){
$key = $_GET["access_token"];
if($key=="b8bc45179e0c022a0a5e7738356549a3ebf3788c"){
$json = array("status" => 1, "msg" => $_SESSION['NAME']);
}else{
$json = array("status" => 0, "msg" => "ACCESS ERROR");
}
header('Content-type: application/json');
echo json_encode($json);
}
It is a success when I call from navigation bar from browser as follows:
https://test.com.mx/p_session.php?access_token=b8bc45179e0c022a0a5e7738356549a3ebf3788c
I get:
{"status":1,"msg":ALIAS}
but when a script from a third party:
<?php
$ch = curl_init('https://test.com.mx/p_session?access_token=b8bc45179e0c022a0a5e7738356549a3ebf3788c');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
calls from the same browser I get:
{"status":1,"msg":null}
Exist way of make this possible?