There are 2 meanings of "header": HTML headers () HTTP headers. ======================================== This is simple, (from viewpt of PHP programming) Clients don't send HTML so don't send headers. PHP server sends it to a client browser as part of HTML text, either simple text or php-echo. PHP acting as client to another server (myfetch), receives it as part of the text; and can extract it. E.g. I extract BASE from the header. ======================================== HTTP headers There are 4 cases, generated by {send, receive} and acting as {client, server} 1) myphp receives cookies from a client browser, with the call that activated the PHP page. $_COOKIES[] 2) myphp sends cookies to a client browser. Must set header before first char of page is emitted. 3) myphp receives cookies as a client to another server (myfetch). Need to get at the hidden HTTP header received. 4) myphp sends cookies as a client to another server (myfetch). Create cookies as part of: one (or more) lines, (terminated by CRLF) inside the "header" part, of the args used by http_build_query(); building a "context"; (stream_context_create($opts);) before (used in) the call (of file_get_contents() ) See "myfilegetcontents" file for code.