{"record":{"id":"a20046d118128e69","repo":"jackwener/OpenCLI","slug":"waiting-for-pixiv-phpsessid-cookie","errorCode":null,"errorMessage":"Waiting for Pixiv PHPSESSID cookie","messagePattern":"Waiting for Pixiv PHPSESSID cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/pixiv/auth.js","lineNumber":60,"sourceCode":"    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('pixiv.net', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Pixiv ajax`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Pixiv whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Pixiv probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'pixiv',\n  domain: 'pixiv.net',\n  loginUrl: 'https://accounts.pixiv.net/login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasPixivSessionCookie,\n  verify: verifyPixivIdentity,\n  poll: async (page) => {\n    if (!await hasPixivSessionCookie(page)) {\n      throw new AuthRequiredError('pixiv.net', 'Waiting for Pixiv PHPSESSID cookie');\n    }\n    return verifyPixivIdentity(page);\n  },\n});\n","sourceCodeStart":42,"sourceCodeEnd":65,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/auth.js#L42-L65","documentation":"This AuthRequiredError is thrown by the pixiv auth poll handler in clis/pixiv/auth.js:60 while waiting for the user to complete the browser login flow. Pixiv only sets a logged-in PHPSESSID cookie whose value is '<numericUserId>_<hash>'; an anonymous session has a bare hash. The poll checks for a cookie matching /^\\d+_/ on https://www.pixiv.net, and throws until the user finishes signing in, so the CLI can keep polling instead of proceeding unauthenticated.","triggerScenarios":"Running the pixiv login/auth command: the poll callback fires, page.getCookies({url:'https://www.pixiv.net'}) returns cookies, but no PHPSESSID exists or its value lacks the numeric uid prefix (anonymous session) at clis/pixiv/auth.js:59.","commonSituations":"User has not yet completed the login form at accounts.pixiv.net; user logged in but Pixiv served an anonymous PHPSESSID (not actually signed in); cookies blocked or cleared mid-flow; login expired so only the bare-hash anonymous PHPSESSID is present; automation raced ahead of the browser navigation.","solutions":["Complete the login in the opened browser window at https://accounts.pixiv.net/login with your Pixiv credentials","Wait and let the poll retry — the error clears once a logged-in PHPSESSID (<uid>_<hash>) is set","Clear cookies for pixiv.net and restart the auth flow if you logged in but still see this (stale anonymous session)","Check the browser profile is not blocking or discarding cookies for accounts.pixiv.net and www.pixiv.net","Re-run the pixiv auth command if your session expired"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const cookies = await page.getCookies({ url: 'https://www.pixiv.net' });\nconst loggedIn = cookies.some(c => c.name === 'PHPSESSID' && /^\\d+_/.test(c.value || ''));\nif (!loggedIn) {\n  console.log('Open the browser and finish the Pixiv login before continuing.');\n}","typeGuard":"function hasPixivSession(cookies) {\n  return Array.isArray(cookies) && cookies.some(\n    c => c && c.name === 'PHPSESSID' && /^\\d+_[A-Za-z0-9]+$/.test(String(c.value || ''))\n  );\n}","tryCatchPattern":"try {\n  await poll(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError && e.message.includes('PHPSESSID')) {\n    // Prompt the user to complete login in the browser, then retry after a delay\n    await promptLoginAndDelay();\n  } else {\n    throw e;\n  }\n}","preventionTips":["Complete the login form promptly in the browser window the CLI opens","Verify cookies are enabled and not cleared for accounts.pixiv.net / www.pixiv.net","If login appears done but polling still fails, clear pixiv.net cookies and restart the auth flow","Check the session has not expired before running batch jobs"],"tags":["auth","cookie","pixiv","login-flow"],"backgroundTag":"auth-session-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}