Welcome Guest, Not a member yet? Register   Sign In
Why "Save Cookies" in cURL Request Class?
#1

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/libra...tml#cookie )
I could not find the option for curl share session ( https://www.php.net/manual/en/function.c...e-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.
Reply
#2

This may help you.

CodeIgniter 4 User Guide - cURL class - cookie
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3
Heart 

from https://www.php.net/manual/en/function.c...e-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);
?>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB