将session保存在不同文件之间的file_get_content中

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
Accept-language: en
" .
               "Cookie: ".session_name()."=".session_id()."
",           
            'method'  => 'POST',
            'content' => http_build_query($data),
        )
    );

    $context  = stream_context_create($options);
    session_write_close();
    $result = file_get_contents($url, false, $context);

Your code is working. Just use session_start() in third block and use full url in file_get_contents.