php - file_get_contents - blank response (PHPSESSID) -
i'm trying download web page php code.
$context_params = array('http' => array('method' => 'get', 'user_agent' => 'mozilla/5.0', 'timeout' => 1, 'header' => "accept-language: en". "cookie: site=blabla1234567cookie; __cf=cookie12345678; phpsessid=phpsessidcookie;")); $context = stream_context_create($context_params); $html = file_get_contents($url, false, $context);
web server checks user verifying cookies. have inserted correct client cookies in context, however, file_get_contents returns blank page phpsessid expires(~1 hour?). tried delete phpsessid cookie on web browser, , loaded webpage generated new phpsessid cookie. didn't require relogin tho. tried remove phpsessid cookie on script, file_get_contents returns blank page.
i tried check this thread, didn't anyhow. still returns blank page, , can't print context array print_r()/var_dump/echo insert session_id() , session_name() in script. (too large?)
session_write_close() makes no difference.
if remove cookies loads page without problems, i'm not logged in.
tried read response blank pages var_dump/echo, , both return blank on $http_response_header right after file_get_contents.
in theory, phpsessid can generated remote server , sent client according cookies , ip address (that explains why working on machine, doesn't work on vps). isn't phpsessid supposed generated on client machine independent of own ip address?
question: how generate/set/renew new correct phpsessid context php script automaticly?
edit: want use file_get_contents. not interested in curl solution @ all.
found solution.
solution: add \r\n @ end of each cookie. otherwise corrupts structure , remote server can complain.
Comments
Post a Comment