CURLOPT_COOKIESESSION.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_COOKIESESSION.md
  2. .TH CURLOPT_COOKIESESSION 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_COOKIESESSION \- start a new cookie session
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long set to 1 to mark this as a new cookie "session". It forces libcurl
  12. to ignore all cookies it is about to load that are "session cookies" from the
  13. previous session. By default, libcurl always loads all cookies, independent if
  14. they are session cookies or not. Session cookies are cookies without expiry
  15. date and they are meant to be alive and existing for this "session" only.
  16. A "session" is usually defined in browser land for as long as you have your
  17. browser up, more or less. libcurl needs the application to use this option to
  18. tell it when a new session starts, otherwise it assumes everything is still in
  19. the same session.
  20. .SH DEFAULT
  21. 0
  22. .SH PROTOCOLS
  23. This functionality affects http only
  24. .SH EXAMPLE
  25. .nf
  26. int main(void)
  27. {
  28. CURL *curl = curl_easy_init();
  29. if(curl) {
  30. CURLcode res;
  31. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  32. /* new "session", do not load session cookies */
  33. curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
  34. /* get the (non session) cookies from this file */
  35. curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
  36. res = curl_easy_perform(curl);
  37. curl_easy_cleanup(curl);
  38. }
  39. }
  40. .fi
  41. .SH AVAILABILITY
  42. Added in curl 7.9.7
  43. .SH RETURN VALUE
  44. Returns CURLE_OK
  45. .SH SEE ALSO
  46. .BR CURLOPT_COOKIE (3),
  47. .BR CURLOPT_COOKIEFILE (3),
  48. .BR CURLOPT_COOKIEJAR (3)