jackwener/OpenCLI · error · AuthRequiredError
Ctrip login_uid cookie absent after navigation
Error message
Ctrip login_uid cookie absent after navigation
What it means
verifyCtripIdentity navigates to my.ctrip.com/myinfo/MyInfoIndex.aspx to confirm the session, then re-reads cookies for www.ctrip.com. If login_uid disappeared after that navigation (it was present in the quick check), it throws AuthRequiredError — the session is effectively invalid even though a cookie existed moments earlier.
Source
Thrown at clis/ctrip/auth.js:20
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
async function hasCtripLoginUid(page) {
const cookies = await page.getCookies({ url: 'https://www.ctrip.com' });
const loginUid = cookies.find(c => c.name === 'login_uid');
return Boolean(loginUid && loginUid.value);
}
async function verifyCtripIdentity(page) {
if (!await hasCtripLoginUid(page)) {
throw new AuthRequiredError('ctrip.com', 'Ctrip login_uid cookie missing — anonymous');
}
await page.goto('https://my.ctrip.com/myinfo/MyInfoIndex.aspx');
await page.wait(2);
const cookies = await page.getCookies({ url: 'https://www.ctrip.com' });
const cookieMap = Object.fromEntries(cookies.map(c => [c.name, c.value]));
const loginUid = cookieMap['login_uid'] || '';
if (!loginUid) {
throw new AuthRequiredError('ctrip.com', 'Ctrip login_uid cookie absent after navigation');
}
const aheadRaw = cookieMap['AHeadUserInfo'] || '';
const params = new URLSearchParams(aheadRaw);
const userNameRaw = params.get('UserName') || '';
let userName = '';
if (userNameRaw) {
try {
userName = decodeURIComponent(userNameRaw);
} catch {
userName = userNameRaw;
}
}
const vipGrade = params.get('VipGrade') || '';
return { user_id: loginUid, name: userName, vip_grade: vipGrade };
}
registerSiteAuthCommands({
site: 'ctrip',View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the login flow (`ctrip login`) to establish a fresh session, then verify again.
- Log out other devices/sessions on Ctrip if concurrent-login invalidation is suspected.
- Retry — if the myinfo page was slow, the cookie may reappear once loaded.
- Check network/IP reputation (VPN/datacenter IP) that could cause Ctrip to drop the session.
Defensive patterns
Strategy: retry
Validate before calling
// verify the session is healthy before dependent commands const identity = await opencli.ctrip.whoami().catch(() => null); if (!identity) await opencli.ctrip.login();
Try / catch
try {
const identity = await opencli.ctrip.whoami();
} catch (err) {
if (err.name === 'AuthRequiredError' && /absent after navigation/i.test(err.message)) {
await opencli.ctrip.login(); // fresh session, then retry
} else throw err;
} Prevention
- Re-login when sessions are old; Ctrip expires sessions server-side.
- Avoid concurrent logins on multiple devices with the same account.
- Retry once before concluding the session is dead (page may have loaded slowly).
- Use a stable, reputable IP; Ctrip drops sessions from suspicious addresses.
When it happens
Trigger: `ctrip login --wait`/verify when the login_uid cookie existed before the myinfo navigation but the server invalidated the session during it — e.g. expired session, kicked-out concurrent login, or the profile page redirecting to a login flow that clears cookies.
Common situations: Stale cookie from a long-ago login that the server rejects; logging in from another device invalidates the old session; Ctrip rotating/clearing login_uid on untrusted-IP access; the myinfo page failing to load fully within the 2s wait.
Related errors
- Ctrip login_uid cookie missing — anonymous
- ${r.detail}
- Bilibili ${label} API requires login or permission: ${messag
- bilibili.com
- BOSS redirected the job detail page to the login flow
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ad8a499f51232f0d.
Report an issue: GitHub.