Using PHP with RPC and cookie Since 0.12 RPC uses a "random cookie":https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.12.0.md#rpc-random-cookie-rpc-authentication for authentication, but it's not clear how to use this cookie when accessing RPC.

I'm trying things like the below, without success (401 Unauthorized)

$Request = array(
    'http' =&gt; array(
        'method' =&gt; 'POST',
        'header' =&gt; "Content-type: application/json\r\n".
                    'Cookie: __cookie__=contentsOf.cookie',
        'content' =&gt; $Params
        )
    );
if (!$Response = file_get_contents(BITCOIN_RPC_URL, false, stream_context_create($Request))) {
    return false;
}


Every example I find online uses the user:pass authentication, I've yet to see an example using cookies.
Not sure if you're still looking for an answer, but I just stumbled upon this myself and for the benefit of anyone running into this.

Even though it's called cookie based authentication, you still authenticate via Basic HTTP.

Let's say your cookie was __cookie__:somerandomlongstring then:


Username __cookie__
Password somerandomlongstring


I figured this out after finding this comment on Github