php - How to allow cURL to automatically add recived cookies to the request? -
i trying communicate resp api using curl calls via php.
the first call api login passing username , password. once api receive request, returns in headers
http/1.1 201 created inin-icws-csrf-token: wahtywxoabcfa1dby2nvukrjwcq2yzg5yefgoc01yti0ltq1mjetytdgdd1imzayngrhzmrjztbycjewljaunc4xnja= inin-icws-session-id: 2562886002 set-cookie: icws_2562886002=1924pe25-d47c-4d07-9546-9fcuijfdd0b02; path=/icws/2562886002 location: /icws/2562886002/connection cache-control: no-cache, no-store, must-revalidate pragma: no-cache expires: 0 access-control-allow-origin: * access-control-allow-credentials: true content-type: application/vnd.inin.icws+json; charset=utf-8 date: thu, 14 may 2015 17:49:20 gmt server: httppluginhost content-length: 238
now, along additional call api, cookie value returned in header must included in new request. (in case: icws_2562886002=1924pe25-d47c-4d07-9546-9fcuijfdd0b02
)
how can configure curl call automatically pass cookie received?
therefore, every request see have cookie: icws_2562886002=1924pe25-d47c-4d07-9546-9fcuijfdd0b02
in header.
i know can manually added this
curl_setopt($ch, curlopt_httpheader, array('cookie: icws_2562886002=1924pe25-d47c-4d07-9546-9fcuijfdd0b02'));
but there has way curl automatically add cookie value request.
i tried add this
curl_setopt($ch, curlopt_cookie, true);
but did not work either
$cookiesfile = 'cookies.txt'; curl_setopt($ch, curlopt_cookiejar, $cookiesfile); // write curl_setopt($ch, curlopt_cookiefile, $cookiesfile); // read
Comments
Post a Comment