file_get_contents (or curl, or fopen) problem with session data

前端 未结 6 1529
情深已故
情深已故 2021-02-11 04:15

i have a page that shows a value from session, lets call it www.domain-a.com/master.php and if i type it directly from the browser, it shows me the session value.

but wh

6条回答
  •  走了就别回头了
    2021-02-11 05:14

    You probably need to send the session ID of the user in a cookie along with the request.

    If you want to use the file_get_contents function, you have to create a context to set a cookie:

    $opts = array(
        'http' => array(
            'method' => 'GET',
            'header' => 'Cookie: PHPSESSID=0123456789abcdef0123456789abcdef'
        )
    );
    $context = stream_context_create($opts);
    echo file_get_contents('http://master.example.com/master.php', 0, $context);
    

提交回复
热议问题