简体   繁体   中英

CURL with PHP codeigniter: keep session on curl requests

I've a basic web service written in Delphi. This web service is receiving POST requests with JSON via PHP Curl Library from Phil used on Codeigniter.

The server returns the data according to the request.

On the first request i send my authentication and i get the respective JSON. On the second request the server identifies a different session.

You need to set CURLOPT_COOKIEFILE so that cURL saves its cookies into a file. The reason you are losing your session is because cURL is not persisting your session cookie across all of your requests.

So, for Code Igniter it would be something like this:

$this->curl->option(CURLOPT_COOKIEFILE,'saved_cookies.txt');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM