【发布时间】:2016-03-22 19:27:41
【问题描述】:
登录.php
session_start();
$_SESSION["login"]=true;
getFile.php
if($_SESSION["login"]==true)
echo "send file";
else
die("you have not access!");
我想先调用 login.php 然后用 file_get_content 或 curl 调用 getFile.php 但是当调用 getFile.php 会话为空时,如何保持会话从 login.php 到 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);
【问题讨论】:
标签: php session curl file-get-contents