English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP curl_share_setopt() Function Usage and Example 5 (PHP 5>=5.
.0)
Syntax
bool curl_share_setopt ( resource $sh , int $option , string $value )
Parameter
sh
The shared handle initialized by curl_share_init().
option | Value |
---|---|
Options | CURLSHOPT_SHARE |
Specify the data type to be shared | CURLSHOPT_UNSHARE |
Specify the data type not to be shared
value | Value |
---|---|
Description | CURL_LOCK_DATA_COOKIE |
Shared cookie data | CURL_LOCK_DATA_DNS |
Shared DNS cache | CURL_LOCK_DATA_SSL_SESSION Shared SSL session ID, reduces the cost of connecting to the same server using SSL |
Return Value
Online Example
This example will create a CURL shared handle and add two CURL handles, both handles share cookie data. // <?php Create a CURL shared handle and set cookie data $sh = curl_share_init(); // curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); Initialize the second CURL handle and specify it as a shared handle1 $ch//Initialize the first CURL handle and specify it as a shared handle3codebox.com/php.net ");1, CURLOPT_SHARE, $sh); // www.w curl_exec($ch1); // Execute the first CURL handle Initialize the second CURL handle and specify it as a shared handle2 $ch//= curl_init("http:/php.net ");2, CURLOPT_SHARE, $sh); // Execute the second CURL handle // All $ch1 The data in the handle $ch2 shared in the handle curl_exec($ch2); // Close CURL shared handle curl_share_close($sh); // Close CURL handle curl_close($ch1); curl_close($ch2); ?>