Short answer: codex logout deletes the login stored in the current CODEX_HOME, which is ~/.codex unless you set it. Every Codex that reads that same folder, including other Terminal tabs and, by default, Codex in the ChatGPT desktop app, loses the login with it. Give each account its own CODEX_HOME and logging out of one leaves the others signed in. Sessions Pro for Codex gives every profile its own, for the app and the CLI.
Free 1-hour preview once you've signed in to a profile. For macOS 14 or later.
Why does logging out in one terminal affect the others?
Codex doesn't keep a login per Terminal window. It keeps one login per folder, inside CODEX_HOME. Every codex you start without setting CODEX_HOME reads ~/.codex, and so does the Codex built into the ChatGPT app for Mac. When codex logout removes that login, all of them are signed out at once, because they were all using the same one.
What shares ~/.codex on a typical Mac?
| What | Uses ~/.codex? |
|---|---|
codex in any Terminal tab | Yes, unless CODEX_HOME is set |
| Codex in the ChatGPT desktop app | Yes, by default |
A tab where you ran export CODEX_HOME=… | No, it uses that folder |
| A Sessions Pro for Codex profile, app or CLI | No, each profile has its own CODEX_HOME |
How do you stop it happening?
Give each account its own folder, so each one has its own login:
mkdir -p ~/.codex-work
CODEX_HOME=~/.codex-work codex
Sign in once there. From then on, codex logout in that tab only clears ~/.codex-work, and plain codex and the desktop app stay signed in. The full setup, with aliases, is in use two Codex CLI accounts in Terminal.
How do you check which folder a terminal is using?
Run echo $CODEX_HOME. If it prints nothing, that tab uses ~/.codex, the shared one. Check before you log out.
Signed out by accident? How do you get back in?
Run codex in that tab, or open the ChatGPT app, and sign in again with the same account. Then set up a folder per account, as above, so the next codex logout only affects the account you meant.
What if you want the desktop app per account too?
CODEX_HOME separates the CLI only; the ChatGPT app keeps using ~/.codex. Sessions Pro for Codex gives each account its own copy of the app with its own CODEX_HOME, and its own CLI that uses the same folder, so signing out of one account never touches another.

Free 1-hour preview once you've signed in to a profile. For macOS 14 or later.
Our guide covers the free alternatives, and ChatGPT's account switcher vs Sessions Pro for Codex explains why the web switcher doesn't change the CLI's login. All approaches side by side: the best ways to run multiple Codex accounts.
FAQ
Does codex logout sign out the ChatGPT desktop app?
It can. By default the Codex in the ChatGPT app and the Codex CLI share ~/.codex, so clearing the login there affects both. Giving the CLI its own CODEX_HOME keeps them apart.
Sessions Pro for Codex is made by LEX GLOBAL IT S.R.L. and is not affiliated with, endorsed by or sponsored by OpenAI. It runs the official ChatGPT app with accounts you already have, and OpenAI's terms apply to each account. ChatGPT and Codex are trademarks of OpenAI.