English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Grundanleitung

PHP Fortgeschrittene Anleitung

PHP & MySQL

PHP Referenzhandbuch

Object function

PHP CURL Reference Manual

PHP curl_share_setopt() function usage and example 5 (PHP 5>=5.

.0)

curl_share_setopt — Set an option for a CURL shared handle.

Syntax

bool curl_share_setopt ( resource $sh , int $option , string $value )

Set an option for a CURL shared handle.

Parameter

sh

The shared handle initialized by curl_share_init().

optionValue
OptionsCURLSHOPT_SHARE
Specify the data type to be sharedCURLSHOPT_UNSHARE

Specify the data type not to be shared

valueValue
DescriptionCURL_LOCK_DATA_COOKIE
Shared cookie dataCURL_LOCK_DATA_DNS
Shared DNS cacheCURL_LOCK_DATA_SSL_SESSION Shared SSL session ID, reduces the cost of connection to the same server on SSL

Time at handshake

Return value

Returns TRUE on success, or FALSE on failure.

Online example

This example will create a CURL shared handle and add two CURL handles, the two 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 handle $ch2 Shared in handle
curl_exec($ch2);
// Close CURL shared handle
curl_share_close($sh);
// Close CURL handle
curl_close($ch1);
curl_close($ch2);
?>

PHP CURL Reference Manual