Twitter (X) Cookies: What auth_token and ct0 Do, and Why Not to Share Them

auth_tokenis your x.com login session. Whoever has its value can act as you, with no password or 2FA prompt.ct0is the anti-CSRF token. Tools echo it in anx-csrf-tokenheader; gallery-dl even generates one when it is missing.- What people post about it: of 219 public X posts about X session cookies, 57.5% involve a tool, script or agent and 30.6% a login, expiry or error problem (collected in 2026).
- The shift: 37.5% of cookie posts from 2025 on name an AI agent or MCP tool, against 4.8% before; security worries rose from 8.4% to 25.7%.
- To clear them: DevTools, Application, Storage, Cookies, then Clear all for
https://x.com; then log out other sessions in X's settings if you ever pasted the value somewhere. - Cookie-free reads:
X-API-Keyonly, no X account, $0.15 per 1,000 tweets vs $0.005 per post read on the official X API (about 33x).
This page is about the x.com cookies themselves: what auth_token, ct0 and the rest are, what happens when you paste them into a tool, and how to clear them. If you came for the gallery-dl configuration (the cookies option, cookies.txt, the browser import), our gallery-dl Twitter guide covers that tool step by step; and if you need to post from code through a logged-in account, the Twitter login and post API guide walks through that flow. Here the subject is the cookie, wherever it ends up.
The question is more common than it looks. Scrapers, video downloaders, desktop clients and, increasingly, AI agents ask users to open their browser's developer tools and copy two values out of x.com. We read the source of four widely used open-source projects to see exactly which cookies they use and how, and we studied 975 public X posts returned by nine cookie searches to see what people run into. The short version: auth_token is a full session, and pasting it is closer to sharing a password than to sharing an API key.
Everything below describes cookie names and behavior from primary sources we read this year (project source code on GitHub, Chrome and MDN documentation, X's help pages). We never collected, stored or tested a real session cookie for this page.
37.5%
The x.com cookies developers meet, one by one
Open x.com in a browser, sign in, and the browser stores a set of cookies for the x.com domain. X publishes a general explanation of how it uses cookies (help.x.com/en/rules-and-policies/x-cookies), grouped by purpose such as authentication, security and preferences, but it does not publish a per-name reference that developers can check. So the reliable way to know what a name does is to read the code of the tools that depend on it. Here is what that code shows.
auth_token. In gallery-dl's Twitter extractor the class declares cookies_names = ("auth_token",): that single name is what the tool checks to decide whether you supplied a login. When it is present, gallery-dl adds the header x-twitter-auth-type: OAuth2Session to its requests. yt-dlp's Twitter extractor does the same test in one line (is_logged_in returns true when the auth_token cookie exists). twscrape refuses cookies without it: its add_account_cookies raises Cookies must include auth_token and ct0. None of these tools needs your password once that value is present, which is the point: the cookie is the proof that a login already happened.
ct0. twikit's client documents its helper as the function that "retrieves the Cross-Site Request Forgery (CSRF) token from the current session's cookies" and reads it from ct0, then sends the value in an X-Csrf-Token header. yt-dlp and gallery-dl do the same. gallery-dl goes one step further: if no ct0 is present it generates a random token, sets it as the ct0 cookie and sends the same value in the header. That tells you what ct0 is for. It is a double-submit check (the server compares the cookie with the header), not a credential by itself, which is also why every tool's instructions ask for it next to auth_token.
gt and the guest flow. For logged-out requests gallery-dl fetches a guest token and stores it as a cookie named gt, caching it for 3,600 seconds; yt-dlp requests one from X's guest activation endpoint. Guest tokens do not identify you. gallery-dl even drops auth_token and retries "as guest" when a target account has blocked yours (with its logout option on), which shows how differently the two credentials are treated.
Everything else. A signed-in browser also carries names such as guest_id and twid (a cookie-export browser add-on on addons.mozilla.org, for example, lists twid among what it exports for twikit). None of the four codebases we read requires them, and X does not describe them name by name, so we do not guess at their purpose here.
How to see and delete Twitter cookies in your browser
Looking at the cookie names is harmless; copying values out is where risk starts. To inspect them, Chrome's DevTools documentation gives the path: open DevTools, then Application, Storage, Cookies, and select the origin (https://x.com). The table shows Name, Value, Domain, Path, Expires / Max-Age, Size, HttpOnly, Secure, SameSite, Partition Key and Priority for each cookie. Firefox has the same view under the Storage tab.
Delete one cookie. Select the row and click Delete selected in the top bar (Chrome's wording).
Delete all x.com cookies. With the https://x.com origin selected, click Clear all. You will be signed out in that browser. For a broader clean-up, every browser also offers a site-data screen in its privacy settings where you can remove everything stored for x.com and twitter.com.
End sessions on X's side too. Deleting a cookie only removes your browser's copy. If a value was ever copied somewhere else (a tool config, a notebook, a chat), that copy is unaffected. X's help page on apps and sessions (help.x.com/en/managing-your-account/connect-or-revoke-access-to-third-party-apps) describes a Sessions list under Settings, Security and account access, Apps and sessions, where each session has a Log out button and the top of the list offers Log out all other sessions. Use that, and change your password if you are unsure where a cookie went.
Read the flags, not the values. The columns that matter for understanding are the flags. MDN's Set-Cookie reference defines them: HttpOnly "forbids JavaScript from accessing the cookie", Secure means the cookie is only sent over https:, SameSite controls whether the cookie travels on cross-site requests and "provides some protection against" cross-site request forgery, and a cookie with no Expires or Max-Age is a session cookie that should end when the browser closes (though session restore can keep it). You can check each flag for auth_token and ct0 in your own browser without copying anything.
Why pasting auth_token into a tool is risky
Tool READMEs make the copy step sound routine. The Node.js twitter-scraper project, for example, tells Firefox users to open DevTools, find the ct0 and auth_token cookies, copy their values and build the string ct0=<value>; auth_token=<value>. twikit offers save_cookies and load_cookies, whose docstrings say you "can skip the login procedure by loading the saved cookies". gallery-dl's cookies-update option is true by default and writes session cookies back to a cookies.txt file. Each of these is reasonable engineering, and each one turns a browser session into a file.
A file is easier to leak than a browser. It ends up in a project folder, a backup, a container image, a notebook cell or a Git commit. During our searches we saw posts that appeared to contain a long hex value right after auth_token= or ct0=; we counted them (3 posts) and stored none of them. Anyone who copies such a value can load it into the same tools.
The session acts as you. Whatever the tool does (paging through timelines, downloading media, following, posting) is done by your account. X can rate-limit, lock or suspend accounts whose activity it considers automated, and the posts we studied include people reporting exactly those outcomes after using their own cookies in scripts.
There is no scope. An API key can be limited, rotated and revoked without touching your account. A session cookie carries whatever your account can do. That is why the safe rules are short: never send a cookie value to a website, a form, a support chat or a third-party service; never commit it; if a tool must run with a session, give it a dedicated account rather than your personal one; and log out the session when you are done.
Malware targets the same files. Several of the security posts in our sample were general warnings about infostealers that copy browser cookies to take over accounts without passwords. That is the same property seen from the other side: a session cookie is the account.
What people post about X session cookies (study)
We searched public X posts with nine cookie-related queries (from auth_token cookie and ct0 auth_token to "twitter cookies" and tool names next to the word cookies) and kept the 219 of 975 unique posts that are actually about X session cookies. The rest were about other cookies: of 80 posts matching "twitter cookies", only 11 were about browser cookies; the others mean the treat or the figure of speech. Themes come from transparent keyword rules (listed in results.json), and one post can carry several.
Tools first. 57.5% of the posts involve a tool, script or agent. The named tools are a mix of downloaders (yt-dlp appears in 51 posts) and newer AI-agent setups that read X through the user's cookies (55 posts name an agent, an MCP server or a coding assistant). Library names that developers search for appear less often in posts than in READMEs: twikit 3, twscrape 2, gallery-dl 1.
Problems second. 30.6% describe something breaking: an expired or empty cookie, being logged out, an error, a verification prompt or a suspended account. That matches what the code shows: a cookie-based tool works only while the session does.
Security worries are rising. Security themes (leaks, stolen sessions, advice to use a burner account) appear in 19.2% of posts overall and draw the highest median likes of any theme (9.5).
Who is posting. 61.2% of the posts are in English, 16.0% in Chinese and 14.2% in Japanese; the Japanese posts in the sample include desktop-client users sharing the auth_token=...;ct0=... input format. 36.5% of posts carry a link and 16.0% link to GitHub, usually to the tool being discussed.

The 2025 shift: AI agents now ask for your cookies
Split by the year of posting, the sample tells a clear story. Of 83 cookie posts from 2024 or earlier, 4.8% mention an AI agent, an MCP server or a coding assistant. Of 136 posts from 2025 on, 37.5% do. The typical recent post presents an open-source agent toolkit that reads X "with zero API keys" by loading the user's auth_token and ct0.
Security talk grew alongside: 8.4% of the older posts touch on leaks, theft or burner accounts, against 25.7% of the recent ones. More people are handing session cookies to automated tools, and more people are noticing what that means.
Why this matters for agents. An agent that holds your session can do anything your account can do, triggered by whatever text it reads. If you wire an agent to X, give it a read path that cannot act as you (an API key for public data) and keep any write path on a dedicated account with explicit, narrow actions.

Reading X data without any cookie
If the goal is public data (posts, profiles, followers, search results), a session cookie is the wrong credential. TwitterAPI.io reads public X data with one header, X-API-Key, which you create in your dashboard. No X account is involved, so nothing about your personal account is exposed and nothing gets rate-limited or locked on it.
Search and timelines. /twitter/tweet/advanced_search takes the same operators as X search (from:, since_time:, lang:, conversation_id:) with queryType=Latest or Top, returns up to 20 posts per page in a top-level tweets array, and pages with has_next_page and next_cursor. /twitter/user/last_tweets returns an account's recent posts under data.tweets.
Profiles and followers. /twitter/user/info returns a profile under data (an unknown user comes back as HTTP 200 with status: "error" and msg: "user not found"). /twitter/user/followers returns about 200 followers per page.
What it costs. Tweet endpoints are 15 credits per tweet returned, which is $0.15 per 1,000 tweets, with a 15-credit minimum per request ($0.00015 for a search that returns nothing; a full 20-post page is $0.003). Profiles are $0.18 per 1,000. The study on this page read 1,094 posts in 68 requests for about $0.16. New accounts get free starter credits (no card, one per person or network, expiring after 31 days); the amount is on the pricing page.
Per 1,000 posts that is about 33x less ($5 / $0.15). The official rate card (docs.x.com/x-api/getting-started/pricing) also caps pay-per-usage at 3 million post reads per monthly billing cycle, with Enterprise above that. Rate limits on TwitterAPI.io are 0.2 requests per second before the first payment, 20 once paid, 50 on Scale and 500 on Business.
import os
import time
import requests
BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]} # an API key, not a browser cookie
def search_posts(query, max_pages=5):
"""Read public posts with advanced_search. No X account and no cookie needed."""
posts, cursor = [], ""
for _ in range(max_pages):
params = {"query": query, "queryType": "Latest"}
if cursor:
params["cursor"] = cursor
r = requests.get(f"{BASE}/twitter/tweet/advanced_search", headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
body = r.json()
posts.extend(body.get("tweets", []))
if not body.get("has_next_page"):
break
cursor = body.get("next_cursor", "")
time.sleep(1) # fixed pacing between pages
return posts
def user_info(user_name):
r = requests.get(f"{BASE}/twitter/user/info", headers=HEADERS, params={"userName": user_name}, timeout=30)
body = r.json()
if body.get("status") == "error": # unknown users come back as http 200 + status error
return None
return body["data"]
if __name__ == "__main__":
for t in search_posts("from:XDevelopers", max_pages=2):
print(t["createdAt"], t["likeCount"], t["viewCount"], t["url"])
u = user_info("XDevelopers")
if u:
print(u["userName"], u["followers"], u["statusesCount"])
When you need to post: a login session you do not copy by hand
Writing (posting, deleting, liking, following, muting, sending a DM) does need a logged-in session, because X ties every action to an account. The difference is how that session is created and held. TwitterAPI.io's /twitter/user_login_v2 takes user_name, email, password, an optional totp_secret (the base32 2FA seed, which the docs strongly recommend) and a proxy you supply, and returns login_cookies. You pass that value to the _v2 write endpoints such as /twitter/create_tweet_v2, /twitter/follow_user_v2 or /twitter/mute_user_v2.
Cost. One login is $0.10 (10,000 credits). Each write is 60 credits, $0.0006 per successful call; calls that return status: error are not charged. The official X API lists $0.015 per post created ($0.20 with a URL), so a plain post is $0.015 vs $0.0006, a 25x ratio.
The caveats are the same as for any session. The call acts as that account, so X can rate-limit, lock or suspend it. Use only your own dedicated account, at a normal human pace; X's automation rules apply, and this is not a way around any limit. A session can need a fresh login. And login_cookies is itself a secret: keep it in memory or a secrets store, never print it, never commit it.
Why this is safer than pasting browser cookies. Your personal browser session never leaves your browser. The automation account is separate, its session is created by code you control, and if it is ever exposed you log that account out without touching your own. The docs note that with an account in good standing and residential proxies the cookies "will generally remain valid indefinitely", so you also avoid repeated manual copy steps.
import os
import requests
BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]}
# One login per dedicated account ($0.10). Credentials come from env vars, never from code.
login = requests.post(f"{BASE}/twitter/user_login_v2", headers=HEADERS, json={
"user_name": os.environ["X_BOT_USERNAME"],
"email": os.environ["X_BOT_EMAIL"],
"password": os.environ["X_BOT_PASSWORD"],
"totp_secret": os.environ.get("X_BOT_TOTP_SECRET", ""), # base32 seed, recommended
"proxy": os.environ["X_BOT_PROXY"], # http://user:pass@host:port, a proxy you supply
}, timeout=60).json()
if login.get("status") != "success":
raise SystemExit(f"login failed: {login.get('message')}")
session = login["login_cookies"] # a secret: keep it in memory or a secrets store, never log it
post = requests.post(f"{BASE}/twitter/create_tweet_v2", headers=HEADERS, json={
"login_cookies": session,
"tweet_text": "Status page updated: all systems normal.",
"proxy": os.environ["X_BOT_PROXY"],
}, timeout=60).json()
print(post.get("status"), post.get("msg") or post.get("message"))
Troubleshooting cookie-based tools
"Login required" or empty results after it worked yesterday. The session ended: you logged out in the browser, X expired it, or the account was challenged. Cookie-based tools cannot renew it; you have to sign in again and re-export, which is the point at which a key-based read path saves time.
A 403 mentioning CSRF. The ct0 cookie and the x-csrf-token header disagree, usually because only auth_token was copied. twikit even ships a helper to remove duplicate ct0 cookies for this reason.
A 401 Unauthorized. On X's own API this means the credentials are missing or invalid for that endpoint; see our page on the Twitter API 401 error. On TwitterAPI.io the only credential is the X-API-Key header.
The account got locked after a scraping run. Automated reading through a personal session counts as activity on that account. Stop the tool, unlock the account through X's prompts, log out other sessions, and move bulk reading to a path that does not use your account.
A tool or website asks you to paste your cookie into a form. Don't. A legitimate service that needs to act for you uses X's OAuth flow, which X lists in the same Apps and sessions screen where you can revoke it.
How we collected this
Question. When people post publicly on X about X's browser session cookies, what are they dealing with: tools, breakage, how-to steps or security?
Query. Nine /twitter/tweet/advanced_search queries with queryType=Latest and -filter:retweets, including auth_token cookie, ct0 auth_token, "twitter cookies", "cookies.txt" (twitter OR x.com), session-cookie phrases and tool names next to the word cookies (all nine are in results.json). Each query was paged until has_next_page was false or 20 pages. 68 requests in total.
Sample. 1,094 posts returned, 975 after removing duplicates, 219 kept by a relevance rule (names auth_token or ct0, or says cookie together with twitter / x.com / tweet and a technical word). Window: every matching post the search returned, from 2014 to 2026; 62.1% were posted in 2025 or later. Collected in 2026.
What the sample cannot show. Search returns what X indexes for these phrases, not every conversation about cookies; private accounts and DMs are absent. Keyword themes are rough: a post that says "error" while describing a tool is counted under both. Posts in languages our keyword lists do not cover may be under-classified. Engagement figures are as of collection.
Privacy. Aggregates only. Raw search pages stayed on our machine and were not published, because the authors are private individuals. The published sample has no post ids, URLs, text, author ids or handles. No cookie value was collected or analyzed; posts that seemed to contain one were only counted.
import os
import time
import requests
BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]} # an API key, not a browser cookie
def search_posts(query, max_pages=5):
"""Read public posts with advanced_search. No X account and no cookie needed."""
posts, cursor = [], ""
for _ in range(max_pages):
params = {"query": query, "queryType": "Latest"}
if cursor:
params["cursor"] = cursor
r = requests.get(f"{BASE}/twitter/tweet/advanced_search", headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
body = r.json()
posts.extend(body.get("tweets", []))
if not body.get("has_next_page"):
break
cursor = body.get("next_cursor", "")
time.sleep(1) # fixed pacing between pages
return posts
def user_info(user_name):
r = requests.get(f"{BASE}/twitter/user/info", headers=HEADERS, params={"userName": user_name}, timeout=30)
body = r.json()
if body.get("status") == "error": # unknown users come back as http 200 + status error
return None
return body["data"]
if __name__ == "__main__":
for t in search_posts("from:XDevelopers", max_pages=2):
print(t["createdAt"], t["likeCount"], t["viewCount"], t["url"])
u = user_info("XDevelopers")
if u:
print(u["userName"], u["followers"], u["statusesCount"])
Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.
Questions readers ask
What is the auth_token cookie on Twitter (X)?
It is the x.com login session cookie. Open-source tools such as gallery-dl, yt-dlp and twscrape check for it to decide that you are logged in, so whoever holds its value can act as your account without your password or a 2FA prompt. Treat it like a password.
What is the ct0 cookie?
ct0 is X's anti-CSRF token. Clients send its value back in an x-csrf-token header and the server compares the two. It is not a login on its own, but tools ask for it together with auth_token because requests fail without a matching pair.
Is it safe to give my Twitter cookies to a tool or website?
Not to a website or a third-party service: never paste a cookie value into a form or a chat. A local open-source tool you run yourself keeps the value on your machine, but it still acts as your account, and the config file can leak. Prefer a dedicated account for any automation, and an API key for reading public data.
How do I delete Twitter cookies?
In Chrome open DevTools, then Application, Storage, Cookies, select https://x.com, and click Clear all (or select one cookie and click Delete selected). Firefox has the same view under the Storage tab, and every browser has a site-data screen in its privacy settings. If a value was ever copied elsewhere, also use Log out all other sessions in X's Apps and sessions settings.
Do Twitter cookies expire?
Each cookie carries its own Expires or Max-Age value, which you can see in the DevTools cookie table. In practice a session also ends when you log out or when X ends it, and cookie-based tools stop working at that point until you sign in and export again.
Can I use the X API without cookies?
Yes for reading. TwitterAPI.io uses only an X-API-Key header and needs no X account; tweets cost $0.15 per 1,000 returned. The official X API uses developer-app credentials (OAuth or bearer tokens), not browser cookies, and charges $0.005 per post read on its pay-per-usage rate card.
Why does my tool say my cookies are invalid?
The session behind them ended (logout, expiry or an account challenge), or only one of the pair was copied so ct0 and the CSRF header do not match. Sign in again in the browser, or move reads to a key-based API that does not depend on a session.
What does user_login_v2 return?
/twitter/user_login_v2 returns login_cookies plus status and message. You pass login_cookies to the _v2 write endpoints. One login is $0.10; each write is $0.0006 per successful call, and calls that return status: error are not charged. Use a dedicated account, keep a normal human pace, and keep the value out of logs.
Continue
- gallery-dl Twitter extractor source (auth_token, ct0, x-csrf-token, gt guest token)
- twikit client source (CSRF token from ct0, save_cookies / load_cookies)
- yt-dlp Twitter extractor source (is_logged_in via auth_token, x-csrf-token from ct0)
- Chrome DevTools: view, edit and delete cookies
- MDN: Set-Cookie (HttpOnly, Secure, SameSite, session cookies)
- TwitterAPI.io docs: user_login_v2 (login_cookies, proxy, totp_secret, price)
- Twitter (X) API overview: endpoints, prices and limits
- gallery-dl Twitter guide: config, cookies option and errors
- twikit: the cookie-based Python library, reviewed
- Twitter login and post API guide
- The X-API-Key header explained
- Twitter API 401 Unauthorized: causes and fixes
- twscrape: account pools and cookies
- Pay-per-use API pricing
- 01B2B on Twitter (X) in 2026: Is It Worth It, and What Actually Works
- 02Twitter (X) Lead Generation: Finding and Qualifying Buyers with Search
- 03Twitter (X) Influencer Marketing: Find and Vet Creators With Data
- 04Twitter (X) and MongoDB: store tweets as documents, upsert by id, query them fast
- 05Supabase + Twitter (X) API: store tweets in Postgres with an Edge Function and pg_cron
- 06X Communities API: How Do You Read Community Posts and Post to a Community?
- 07Twitter (X) Geolocation: What Location Data X Still Exposes, and How to Read It
- 08x-rate-limit-reset and the Other Twitter (X) API Rate-Limit Headers, Decoded
Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.
Stop reading. Start building.
Starter credits cover real testing on real data. Google sign-in, no card, no application queue.
Get an API keyAlready building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.