Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_SHARE.3
index 6a0c7b8..d326b4a 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -20,7 +20,8 @@
 .\" *
 .\" **************************************************************************
 .\"
-.TH CURLOPT_SHARE 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
+.TH CURLOPT_SHARE 3 "May 31, 2017" "libcurl 7.59.0" "curl_easy_setopt options"
+
 .SH NAME
 CURLOPT_SHARE \- specify share handle to use
 .SH SYNOPSIS
@@ -50,7 +51,29 @@ NULL
 .SH PROTOCOLS
 All
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+CURL *curl2 = curl_easy_init(); /* a second handle */
+if(curl) {
+  CURLSH *shobject = curl_share_init();
+  curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
+
+  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
+  curl_easy_setopt(curl, CURLOPT_SHARE, shobject);
+  ret = curl_easy_perform(curl);
+  curl_easy_cleanup(curl);
+
+  /* the second handle shares cookies from the first */
+  curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second");
+  curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, "");
+  curl_easy_setopt(curl2, CURLOPT_SHARE, shobject);
+  ret = curl_easy_perform(curl2);
+  curl_easy_cleanup(curl2);
+
+  curl_share_cleanup(shobject);
+}
+.fi
 .SH AVAILABILITY
 Always
 .SH RETURN VALUE