Welcome Guest, Not a member yet? Register   Sign In
CurlRequest Cookies not working
#1

Hello,

I'm migrating an CI3 app to CI4 (4.4.3) and I have problem to make CurlRequest working fine with cookies.
In CI3, I used plain old PHP curl : 

PHP Code:
$ch curl_init();
curl_setopt($chCURLOPT_COOKIESESSIONTRUE);
curl_setopt($chCURLOPT_COOKIEJAR$cookieFile);
curl_setopt($chCURLOPT_COOKIEFILE$cookieFile);
curl_setopt($chCURLOPT_URL$loginUrl));
$content curl_exec($ch); 


This work fine and my cookie file looks like this : 

Code:
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

192.168.1.12    FALSE  /      FALSE  0      sid    12271



When I try to do the same in CI4 with the following code :

PHP Code:
$options = [
            'cookie' => $ookieFile,
];
$curlRequest = \Config\Services::curlrequest($options);
$response $curlRequest->get($oginUrl); 


No cookie is used and the cookie file is empty : 
Code:
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

It seems it's missing something like CURLOPT_COOKIESESSION 

Do you have any idea ?

Thanks,

Fred
Reply


Messages In This Thread
CurlRequest Cookies not working - by Fred9176 - 12-12-2023, 06:19 AM
RE: CurlRequest Cookies not working - by kenjis - 12-12-2023, 03:19 PM
RE: CurlRequest Cookies not working - by Fred9176 - 12-13-2023, 01:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB