Glossary
cf_clearance cookie
cf_clearance is the cookie a browser receives after passing a Cloudflare challenge; it lets later requests through without another check, as long as they come from the same client.
Definition
When a visitor passes a managed challenge or one of Cloudflare's older JS and interactive challenges, the final response sets a cookie named cf_clearance on the site's domain. The value is an opaque string. As long as it is valid, Cloudflare's edge recognises the visitor as already checked and forwards requests straight to the origin.
The cookie is a permission slip, not an identity. It does not log you in or carry account data; it only records that a check was passed under certain conditions.
What it is bound to
Cloudflare ties the clearance to properties of the client that earned it. In practice, two of them matter most for automation:
- The IP address. A cookie earned from one exit IP is generally rejected from another, and the visitor is challenged again.
- The user agent. Requests must send the same
User-Agentstring. Changing browsers, or letting an HTTP library send its default header, voids the cookie.
Other connection traits, such as the TLS fingerprint, can also be compared on some sites. That is why plain HTTP clients sometimes still fail with a valid cookie and the right header: the connection itself looks different from the browser that passed. Libraries that imitate browser TLS help in those cases.
How long it lasts
Lifetime is set by the site owner through Cloudflare's "challenge passage" setting. Common values range from about 15 minutes to a few hours, and the maximum allowed is longer still. The cookie's Expires attribute gives a hint, but Cloudflare can also invalidate it earlier, for example when the bot score for the session drops or a rule changes. Plan for reuse over a working session, not over days.
Getting one through GateSolver
The Cloudflare Challenge task passes the check through your own proxy and returns the cookie and the user agent together:
"solution": {"cookies": {"cf_clearance": "Bcg6jNLz..."}, "token": "Bcg6jNLz...",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) ..."}
Use all three pieces as one unit: the same proxy you put in the task, the returned userAgent, and the cf_clearance value in your cookie jar. If any one of them changes, expect a fresh challenge. The proxy requirement is also why this task is not proxyless; see proxyless task for the general rule.
Reusing it efficiently
One solve can cover many requests. A simple pattern is a cache keyed by proxy: store the cookie, user agent and the time you got it, reuse it while responses come back with status 200, and drop it the moment a response turns into a challenge page again. With sticky residential or ISP proxies, a single clearance can carry a scraping session for a long stretch. With rotating proxies that change IP per request, every new IP needs its own clearance, which makes the per-request cost much higher.
def fetch(session, url, clearance):
session.cookies.set("cf_clearance", clearance["cookie"])
session.headers["User-Agent"] = clearance["ua"]
return session.get(url, proxies=clearance["proxies"], timeout=30)
Signs the cookie stopped working
Watch for a 403 or 503 status with the "Just a moment" page, or a cf-mitigated header. Treat that as the signal to solve again. Repeated challenges right after a fresh solve usually mean the request did not match: wrong user agent, a different exit IP behind a rotating gateway, or headers that a real browser would never send in that order. The reuse guide works through each of these.
If you run several workers, give each its own proxy and its own clearance rather than sharing one cookie through a central store. Sharing looks efficient but fails as soon as two workers exit from different IPs.
Common questions
Can I share one cf_clearance between several proxies?
Generally no. Each exit IP needs its own clearance, because Cloudflare binds the cookie to the address that passed the check.
How do I know how long my cookie is valid?
Read its Expires attribute as a rough guide, then rely on responses: when a challenge page returns, the clearance is no longer accepted.
Why is my cookie rejected immediately?
The usual causes are a different user agent, a rotating proxy that changed IP, or a client whose TLS fingerprint looks unlike a browser.
Is cf_clearance a login cookie?
No. It only records that a challenge was passed and carries no account information.
Do I pay again for every request that uses the cookie?
No. You pay once per solved task; every request you send with the cookie afterwards costs nothing extra.
Keep reading
- Managed challengeCloudflare's full-page check that picks between a silent test and an interactive one, ending in a cf_clearance cookie.
- Reusing cf_clearance cookies safelyDesign sessions around cf_clearance: bind each cookie to one IP and user agent, track its age and refresh only when needed.
- Proxyless taskTasks the solver completes from its own network versus tasks that run through your proxy, and how to pick between them.
- Cloudflare Challenge solver$0.84 per 1,000 tasks, answers under 10 seconds.