Comparisons

Token-Based vs Cookie-Based CAPTCHA Solving

CAPTCHA solutions come in two forms: tokens that you inject into form submissions, and cookies that grant session-level access. Choosing the right approach depends on which CAPTCHA you're facing and how the target site validates it.


At a glance

Aspect Token-based Cookie-based
Output A string token (500+ chars) A browser cookie (cf_clearance, etc.)
Used for reCAPTCHA v2/v3, hCaptcha, Turnstile Cloudflare Challenge pages
How it's used Injected into form field or POST body Sent with subsequent HTTP requests
Lifetime 60-120 seconds 30 minutes to 24 hours
Reusable No (single use) Yes (for the session duration)
Browser required For extraction only For solving (full browser needed)

Token-based solving

How it works

  1. Extract the sitekey from the page
  2. Submit sitekey + page URL to CaptchaAI
  3. Receive a token string
  4. Inject the token into the hidden form field
  5. Submit the form

Which CAPTCHAs use tokens

  • reCAPTCHA v2: Token goes into g-recaptcha-response textarea
  • reCAPTCHA v3: Same field, but also need action and min_score
  • hCaptcha: Token goes into h-captcha-response
  • Turnstile: Token goes into cf-turnstile-response

Implementation

import requests
import time

API_KEY = "YOUR_API_KEY"

# 1. Solve
resp = requests.post("https://ocr.captchaai.com/in.php", data={
    "key": API_KEY,
    "method": "userrecaptcha",
    "googlekey": "6Le-wvkSAAAAAPBMR...",
    "pageurl": "https://example.com/login",
    "json": "1",
}).json()
task_id = resp["request"]

# 2. Poll
token = None
for _ in range(24):
    time.sleep(5)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY, "action": "get", "id": task_id, "json": "1"
    }).json()
    if result["status"] == 1:
        token = result["request"]
        break

# 3. Submit form with token (no browser needed)
form_response = requests.post("https://example.com/login", data={
    "email": "user@example.com",
    "password": "password",
    "g-recaptcha-response": token,
})

Key characteristics

  • No browser needed for submission: You can inject the token directly into an HTTP POST request
  • Short-lived: Tokens expire in 60-120 seconds — solve and use immediately
  • Single use: Each token works once; solve again for each form submission
  • Server-side validation: The target site sends the token to Google/Cloudflare/hCaptcha for verification

How it works

  1. A challenge page is served (Cloudflare Challenge, JS Challenge)
  2. A browser solves the challenge (may involve Turnstile internally)
  3. The server sets a session cookie (cf_clearance)
  4. All subsequent requests with that cookie skip the challenge

Which CAPTCHAs use cookies

  • Cloudflare Challenge pages: cf_clearance cookie
  • JS Challenge: Cloudflare JavaScript-only challenge
  • Some WAF challenges: Various Web Application Firewalls

Implementation

from selenium import webdriver
import requests
import time

# 1. Solve the challenge in a browser
driver = webdriver.Chrome()
driver.get("https://example.com/protected")

# Wait for challenge to complete (manually or with CaptchaAI)
time.sleep(10)  # Or use CaptchaAI token injection

# 2. Extract cookies from browser
cookies = driver.get_cookies()
cf_clearance = next(
    (c for c in cookies if c["name"] == "cf_clearance"), None
)
user_agent = driver.execute_script("return navigator.userAgent")
driver.quit()

# 3. Use cookies for subsequent requests (no browser needed)
session = requests.Session()
session.headers.update({"User-Agent": user_agent})

for cookie in cookies:
    session.cookies.set(cookie["name"], cookie["value"])

# All requests now pass the challenge
for page in range(1, 50):
    resp = session.get(f"https://example.com/api/data?page={page}")
    print(f"Page {page}: {resp.status_code}")

Key characteristics

  • Browser required for solving: The challenge needs a full browser environment
  • Long-lived: Cookies last 30 minutes to 24 hours
  • Reusable: One solve grants access to many requests
  • IP-bound: The cookie is tied to the IP that solved the challenge
  • UA-bound: The User-Agent must match the one used during solving

When to use which

Scenario Approach Why
Login form with reCAPTCHA Token Submit token with form data
Scraping a Cloudflare-protected site Cookie One solve, many page requests
Form submission with Turnstile Token Inject into cf-turnstile-response
Accessing an API behind Cloudflare Cookie Reuse cookie for all API calls
Submitting multiple forms Token (each time) Each form needs a fresh token
Bulk scraping same domain Cookie Solve once, scrape until cookie expires

Hybrid approach

Some sites use both: a Cloudflare Challenge page (cookie) protecting a form that has reCAPTCHA (token).

# Step 1: Get past Cloudflare (cookie)
session = get_cf_clearance_session("https://example.com")

# Step 2: Load the form (using the cookie session)
html = session.get("https://example.com/submit").text
sitekey = extract_sitekey(html)

# Step 3: Solve reCAPTCHA (token)
token = solve_recaptcha(sitekey, "https://example.com/submit")

# Step 4: Submit form (cookie + token)
resp = session.post("https://example.com/submit", data={
    "data": "value",
    "g-recaptcha-response": token,
})

Comparison summary

Feature Token Cookie
Solve cost Per form submission Per session (amortized)
Solve time 10-30s per token 10-30s once
Requests per solve 1 Many (until expiry)
IP flexibility Token works from any IP Cookie tied to solving IP
Browser for use Not needed Not needed (just the cookie)
Expiry risk 60-120s 30 min - 24 hours

FAQ

No. The approach depends on how the site validates. reCAPTCHA always uses tokens; Cloudflare Challenge always uses cookies.

Which is cheaper for high-volume scraping?

Cookie-based is far cheaper when available. One solve covers thousands of requests. Token-based requires a solve per form submission.

Does CaptchaAI handle both?

Yes. Token-based CAPTCHAs return a token string. For Cloudflare Challenge pages, you can use the Turnstile solver to get the token needed to complete the challenge, then extract the resulting cookie.


Solve CAPTCHAs with CaptchaAI

Get your API key at captchaai.com.


Discussions (0)

No comments yet.

Related Posts

Comparisons Migrate from Anti-Captcha to CaptchaAI Step by Step
Step-by-step guide to migrate from Anti-Captcha's custom JSON API to Captcha AI's 2 Captcha-compatible format.

Step-by-step guide to migrate from Anti-Captcha's custom JSON API to Captcha AI's 2 Captcha-compatible format....

Automation Python All CAPTCHA Types
Mar 16, 2026
Comparisons Migrate from CapSolver to CaptchaAI Step by Step
Step-by-step guide to migrate from Cap Solver to Captcha AI.

Step-by-step guide to migrate from Cap Solver to Captcha AI. API differences, code examples, and why Captcha A...

Automation Python All CAPTCHA Types
Feb 23, 2026
Comparisons Migrate from 2Captcha to CaptchaAI Step by Step
Complete step-by-step migration guide from 2 Captcha to Captcha AI.

Complete step-by-step migration guide from 2 Captcha to Captcha AI. Same API format — change the URL and API k...

Automation Python All CAPTCHA Types
Feb 23, 2026
Explainers CaptchaAI JSON API vs Form API: Which Format to Use
Compare Captcha AI's JSON and form-encoded API formats.

Compare Captcha AI's JSON and form-encoded API formats. Learn when to use each, with code examples in Python a...

Automation Python All CAPTCHA Types
Feb 20, 2026
Reference Migrate from AZCaptcha to CaptchaAI: Complete Guide
Step-by-step migration from AZCaptcha to Captcha AI — endpoint mapping, parameter differences, code changes, and parallel testing for a safe transition.

Step-by-step migration from AZCaptcha to Captcha AI — endpoint mapping, parameter differences, code changes, a...

Automation Python All CAPTCHA Types
Feb 09, 2026
Comparisons Parallel vs Sequential CAPTCHA Solving: Performance Trade-offs
Compare parallel and sequential CAPTCHA solving approaches — throughput, resource usage, cost, and complexity trade-offs with Captcha AI examples.

Compare parallel and sequential CAPTCHA solving approaches — throughput, resource usage, cost, and complexity...

Automation Python All CAPTCHA Types
Feb 01, 2026
Reference Migrate from NextCaptcha to CaptchaAI: Complete Guide
Migrate from Next Captcha to Captcha AI — endpoint mapping, parameter translation, code examples in Python and Java Script, and a parallel testing strategy.

Migrate from Next Captcha to Captcha AI — endpoint mapping, parameter translation, code examples in Python and...

Automation Python All CAPTCHA Types
Jan 30, 2026
Reference Migrate from EndCaptcha to CaptchaAI: API Mapping Guide
Map End Captcha API calls to Captcha AI equivalents — endpoint changes, parameter differences, code examples, and a step-by-step migration plan.

Map End Captcha API calls to Captcha AI equivalents — endpoint changes, parameter differences, code examples,...

Automation Python All CAPTCHA Types
Jan 20, 2026
DevOps & Scaling Blue-Green Deployment for CAPTCHA Solving Infrastructure
Implement blue-green deployments for CAPTCHA solving infrastructure — zero-downtime upgrades, traffic switching, and rollback strategies with Captcha AI.

Implement blue-green deployments for CAPTCHA solving infrastructure — zero-downtime upgrades, traffic switchin...

Automation Python All CAPTCHA Types
Apr 07, 2026
Reference CAPTCHA Solving Performance by Region: Latency Analysis
Analyze how geographic region affects Captcha AI solve times — network latency, proxy location, and optimization strategies for global deployments.

Analyze how geographic region affects Captcha AI solve times — network latency, proxy location, and optimizati...

Automation Python All CAPTCHA Types
Apr 05, 2026
Comparisons WebDriver vs Chrome DevTools Protocol for CAPTCHA Automation
Compare Web Driver and Chrome Dev Tools Protocol (CDP) for CAPTCHA automation — detection, performance, capabilities, and when to use each with Captcha AI.

Compare Web Driver and Chrome Dev Tools Protocol (CDP) for CAPTCHA automation — detection, performance, capabi...

Automation Python reCAPTCHA v2
Mar 27, 2026
Comparisons ISP Proxies vs Datacenter Proxies for CAPTCHA Solving
Compare ISP and datacenter proxies for CAPTCHA solving — detection rates, speed, cost, and which works best with Captcha AI.

Compare ISP and datacenter proxies for CAPTCHA solving — detection rates, speed, cost, and which works best wi...

reCAPTCHA v2 Cloudflare Turnstile reCAPTCHA v3
Apr 05, 2026
Comparisons GeeTest vs reCAPTCHA
Compare Gee Test and re CAPTCHA side by side.

Compare Gee Test and re CAPTCHA side by side. Learn about challenge types, detection methods, solving approach...

Automation reCAPTCHA v3 Migration
Apr 01, 2026