jackwener/OpenCLI · error · AuthRequiredError
Pixiv PHPSESSID prefix unparseable
Error message
Pixiv PHPSESSID prefix unparseable
What it means
Inside the in-page probe, after the global-data meta tag and /ajax/user/extra both fail to yield a user id, the code parses the PHPSESSID cookie's `<uid>_` prefix to identify the user. If that prefix is empty/unparseable, the probe returns kind='auth' with detail 'Pixiv PHPSESSID prefix unparseable' and verifyPixivIdentity throws AuthRequiredError — the session cookie exists but doesn't identify a logged-in user.
Source
Thrown at clis/pixiv/auth.js:44
}
const r = await fetch('/ajax/user/extra', { credentials: 'include', headers: { Accept: 'application/json' } });
if (r.status === 401 || r.status === 403) {
return { kind: 'auth', detail: 'Pixiv /ajax/user/extra HTTP ' + r.status };
}
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
if (d?.error) return { kind: 'auth', detail: 'Pixiv /ajax/user/extra error=true — anonymous' };
const phpSess = (document.cookie.split('; ').find(c => c.startsWith('PHPSESSID=')) || '').split('=')[1] || '';
const uid = phpSess.split('_')[0] || '';
if (!uid) {
return { kind: 'auth', detail: 'Pixiv PHPSESSID prefix unparseable' };
}
return { ok: true, user_id: uid, name: '' };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (probe?.kind === 'auth') throw new AuthRequiredError('pixiv.net', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Pixiv ajax`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Pixiv whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Pixiv probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name };
}
registerSiteAuthCommands({
site: 'pixiv',
domain: 'pixiv.net',
loginUrl: 'https://accounts.pixiv.net/login',
columns: ['user_id', 'name'],
quickCheck: hasPixivSessionCookie,
verify: verifyPixivIdentity,
poll: async (page) => {
if (!await hasPixivSessionCookie(page)) {
throw new AuthRequiredError('pixiv.net', 'Waiting for Pixiv PHPSESSID cookie');
}
return verifyPixivIdentity(page);View on GitHub (pinned to 49907e53dc)
Solutions
- Complete the pixiv login flow again so a properly `<uid>_hash`-shaped PHPSESSID is issued.
- Delete the stale anonymous PHPSESSID cookie for pixiv.net, then log in fresh.
- Check whether pixiv removed the `global-data` meta tag and update the probe to rely on /ajax/user/extra user data.
- Verify logged-in state in the browser before running auth-required pixiv commands.
Defensive patterns
Strategy: validation
Validate before calling
const sess = (document.cookie.split('; ').find(c => c.startsWith('PHPSESSID=')) || '').split('=')[1] || '';
if (!/^\d+_.+/.test(sess)) {
// anonymous or malformed session — trigger a fresh login before probing identity
await relogin();
} Type guard
function isAuthedPixivSession(phpsessid) {
return typeof phpsessid === 'string' && /^\d+_.+/.test(phpsessid);
} Try / catch
try {
await pixivWhoAmI();
} catch (err) {
if (String(err.message).includes('PHPSESSID prefix unparseable')) {
await clearCookie('PHPSESSID', 'https://www.pixiv.net');
await interactiveLogin('https://accounts.pixiv.net/login');
await pixivWhoAmI();
} else throw err;
} Prevention
- Complete the login flow fully; do not interrupt accounts.pixiv.net mid-sign-in.
- Clear stale anonymous PHPSESSID cookies before logging in.
- Prefer reading the user id from /ajax/user/extra rather than the cookie prefix when available.
When it happens
Trigger: PHPSESSID present but its value lacks a numeric underscore prefix (anonymous/bare-hash session cookie), while the global-data meta tag is absent (pixiv A/B test, page variant, or SPA change) and /ajax/user/extra returns a non-error anonymous payload.
Common situations: Login half-completed: anonymous cookie set before the authenticated one; cookie manually copied from an anonymous browsing session; pixiv changed the global-data meta tag so the fallback path runs; regional/logged-out pixiv variant serving no global-data.
Related errors
- Pixiv PHPSESSID cookie missing
- Waiting for Pixiv PHPSESSID cookie
- Waiting for Ctrip login_uid cookie
- ${probe.detail}
- my.hupu.com
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/59e2d37a93b72108.
Report an issue: GitHub.