CURLOPT_COOKIESESSION(3)
π CURLOPT_COOKIESESSION π
okay so this is a page from the Library Functions Manual, bestie β CURLOPT_COOKIESESSION β and it's literally about starting a brand new cookie session. iykyk πͺβ¨
πΈ NAME πΈ
CURLOPT_COOKIESESSION β start a new cookie session π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init);
π DESCRIPTION π
so you pass a long set to 1 to mark this as a new cookie "session". what that does, lowkey, is force libcurl to ignore all the cookies it's about to load that are "session cookies" from the previous session. like, ghost them π
by default, libcurl always loads all cookies β doesn't matter if they're session cookies or not, it's loading them all, no questions asked. and session cookies are the ones without an expiry date, and they're meant to be alive and existing for this "session" only. main character energy but make it temporary π«Ά
now, a "session" in browser land is usually defined as, like, as long as you have your browser up β more or less. π and here's the thing: libcurl needs the application to use this option to tell it when a new session starts. otherwise it just assumes everything is still the same session. it's not a mind reader, bestie π
π DEFAULT π
0
π¦ PROTOCOLS π¦
this functionality affects http only π
π₯ EXAMPLE π₯
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
/* new "session", do not load session cookies */
curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
/* get the (non session) cookies from this file */
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
β AVAILABILITY β
added in curl 7.9.7 β vintage but iconic π
π§ RETURN VALUE π§
curl_easy_setopt(3) returns a CURLcode indicating success or error β that's the vibe check for whether it worked.
CURLE_OK (0) means everything was OK. a non-zero value means an error occurred β go see libcurl-errors(3). π
π» SEE ALSO π»
and that's the whole page, bestie!! π this one came from libcurl and it's dated 2026-10-12 β so like, note the date for your records, mwah πβ¨ slay!
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms