login.php
session_start();
$_SESSION["login"]=true;
getFile.php
if($_SESSION["login"]==true)
echo "send file";
else
die("you have not access!");
I want first call login.php and then getFile.php with file_get_content or curl but when call getFile.php session is empty how can keep session from login.php to getfile.php?
$options = array(
'http' => array(
'header'=>"Content-type: application/x-www-form-urlencoded\r\nAccept-language: en\r\n" .
"Cookie: ".session_name()."=".session_id()."\r\n",
'method' => 'POST',
'content' => http_build_query($data),
)
);
$context = stream_context_create($options);
session_write_close();
$result = file_get_contents($url, false, $context);