CodeIgniter Forums
Why "Save Cookies" in cURL Request Class? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Why "Save Cookies" in cURL Request Class? (/showthread.php?tid=80657)



Why "Save Cookies" in cURL Request Class? - renela - 11-28-2021

Hi all,
In my project I will need cURL and I don't like Guzzle at all,
before I wrote my own cURL Class, I read the user guide to know if the class could do all that I want....

So, I read the topic Cookie ( https://codeigniter.com/user_guide/libraries/curlrequest.html#cookie )
I could not find the option for curl share session ( https://www.php.net/manual/en/function.curl-share-init.php ) and ( https://curl.se/libcurl/c/curl_share_init.html )
Dont need to "save cookie" and "read cookie" after and before each request.
Could it be part of Codeigniter cURL Class?
Thank you.


RE: Why "Save Cookies" in cURL Request Class? - InsiteFX - 11-29-2021

This may help you.

CodeIgniter 4 User Guide - cURL class - cookie


RE: Why "Save Cookies" in cURL Request Class? - renela - 12-12-2021

from https://www.php.net/manual/en/function.curl-share-init.php
Codeigniter could have this option?
PHP Code:
<?php
// Create cURL share handle and set it to share cookie data
$sh curl_share_init(); // <-----------
curl_share_setopt($shCURLSHOPT_SHARECURL_LOCK_DATA_COOKIE);

// Initialize the first cURL handle and assign the share handle to it
$ch1 curl_init("http://example.com/");
curl_setopt($ch1CURLOPT_SHARE$sh);

// Execute the first cURL handle
curl_exec($ch1);

// Initialize the second cURL handle and assign the share handle to it
$ch2 curl_init("http://php.net/");
curl_setopt($ch2CURLOPT_SHARE$sh);

// Execute the second cURL handle
//  all cookies from $ch1 handle are shared with $ch2 handle <----------------
curl_exec($ch2);

// Close the cURL share handle
curl_share_close($sh);

// Close the cURL handles
curl_close($ch1);
curl_close($ch2);
?>