PHP文件\u get\u contents()和PHPSESSID

PHP文件\u get\u contents()和PHPSESSID,php,session,cookies,file-get-contents,Php,Session,Cookies,File Get Contents,我无法将文件内容与会话cookie一起使用!有9块饼干。。我的代码: <? $ip=explode('<a href="trade?t=',file_get_contents('http://csgolounge.com/')); $ip=explode('">',$ip[1]); $ip=$ip[0]; echo $ip; $opts = array( 'http' => array( 'method' => 'GET',

我无法将文件内容与会话cookie一起使用!有9块饼干。。我的代码:

<?
$ip=explode('<a href="trade?t=',file_get_contents('http://csgolounge.com/'));
$ip=explode('">',$ip[1]);
$ip=$ip[0];
echo $ip;

$opts = array(
    'http' => array(
        'method' => 'GET',
        'header' => 'Cookie: __utma=123\r\n__utmb=123\r\n__utmc=123\r\n__utmt=123\r\n__utmz=123\r\nid=123\r\nPHPSESSID=123\r\ntkz=123\r\ntoken=123\r\n'));
$context = stream_context_create($opts);

session_write_close();
$ip2=explode('<a class="buttonright" href="',file_get_contents('http://csgolounge.com/trade?t=' . $ip, false, $context)); // This doesn't return the url...
$ip2=explode('">Add on Steam</a>',$ip2[1]);
$ip2=$ip2[0];
echo $ip2;
?>

我做错了什么?
请帮忙

Cookie标题中的Cookie使用分号(而不是换行符)分隔

您的
Cookie
标题应如下所示:

'header' => 'Cookie: __utma=123; __utmb=123; __utmc=123; __utmt=123; __utmz=123; id=123; PHPSESSID=123; tkz=123; token=123'

你能解释一下你想做什么吗?试图从csgolounge.com获取url(steam://friends/add/xxxxxxxxxxxxxxxxxxxx)尝试使用html解析器,就像没有会话cookies我无法解析一样……当然可以,因为file_get_contents返回可以解析的html字符串