Note that there are some explanatory texts on larger screens.

plurals
  1. POSend cookies via HttpRequest in PHP along with request
    primarykey
    data
    text
    <p>I've got a PBX server (Asterisk 1.8), and I'm able to manage calls via some GET variables in a request. My issue is that I need to first login to the server. Once I've done so I want to save a cookie, and then send it along for verification along with my next requestion.</p> <p>I have code that currently works using cURL:</p> <pre><code>public function authenticate(){ $temp_dir = sys_get_temp_dir(); $ckfile = tempnam($temp_dir, "ast"); $auth_url = $this-&gt;ast_link."?action=login&amp;username=asterisk_http&amp;secret=*****"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $auth_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $auth_response = curl_exec($ch); curl_close($ch); $this-&gt;auth_cookie = $ckfile; return $ckfile; } //$call contains id, patcode, phone_number, call_type public function makeCall($overload, $call, $exten, $user = NULL){ set_time_limit(0); if(!$this-&gt;auth_cookie) $this-&gt;authenticate(); //http://blah.server/asterisk/rawman?action=originate&amp;channel=$somechannel $call_url = $this-&gt;generateCallUrl($overload, $call, $exten, $user); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $call_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, $this-&gt;auth_cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); return $response; } </code></pre> <p>Unfortunately cURL waits for a response from the server, which only happens at the end of a call. Because of this I'm unable to make multiple calls simultaneously.</p> <p>How could I use HttpRequest in PHP to send a cookie along with the request in the same way that cURL does? I'm a little unfamilliar with the networking mechanics behind this, so forgive me for my ignorance on this.</p> <p>TL;DR: How to send cookie along with HttpRequest</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload