{"record":{"id":"8a110b47e5f072be","repo":"jackwener/OpenCLI","slug":"linkedin-jsessionid-cookie-not-found-please-sign-8a110b","errorCode":null,"errorMessage":"LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.","messagePattern":"LinkedIn JSESSIONID cookie not found\\. Please sign in to LinkedIn\\.","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/inbox.js","lineNumber":188,"sourceCode":"    // SPA was slow to issue it.\n    let located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));\n    if (located && located.loginRequired) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn requires an active signed-in browser session.');\n    }\n    if (!located || !located.url) {\n      await page.wait(6);\n      located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));\n    }\n    if (!located || !located.url) {\n      throw new CommandExecutionError(\n        'LinkedIn did not issue a messaging API request; the inbox may have failed to load.',\n      );\n    }\n\n    const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\n    const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\n    if (!jsession) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.');\n    }\n    const csrf = jsession.replace(/^\"|\"$/g, '');\n\n    // Widen the page size to the requested limit where the query supports it.\n    const targetUrl = located.url.replace(/count:\\d+/, 'count:' + limit);\n    const fetched = unwrapEvaluateResult(\n      await page.evaluate(`(${fetchMessagingApi.toString()})(${JSON.stringify(targetUrl)}, ${JSON.stringify(csrf)})`),\n    );\n    if (fetched && fetched.authRequired) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn messaging API authentication failed: ' + fetched.error);\n    }\n    if (!fetched || fetched.error || !fetched.json) {\n      throw new CommandExecutionError(\n        'LinkedIn messaging API returned an unexpected response: ' + ((fetched && fetched.error) || 'no data'),\n      );\n    }\n\n    let conversations = parseConversations(fetched.json, located.mailboxUrn || '');","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/inbox.js#L170-L206","documentation":"After locating the messaging API request, the CLI reads the JSESSIONID cookie from the linkedin.com cookie jar to build the CSRF token (csrf). If no JSESSIONID cookie exists, an AuthRequiredError is thrown because API calls from the page context cannot succeed without it. This is a second, cookie-level authentication check on top of the page-level login check.","triggerScenarios":"page.getCookies({ url: 'https://www.linkedin.com' }) contains no cookie named JSESSIONID when processing `linkedin inbox` — the authenticated-page check (2321) passed but the session cookie is absent.","commonSituations":"Cookie cleared by the browser or an extension, session freshly downgraded (logged out in another tab), HttpOnly/secure cookie scope changes, or pointing getCookies at a URL whose cookie scope excludes the session cookie.","solutions":["Sign in to LinkedIn in the automated browser profile and re-run the command.","Verify JSESSIONID exists: document.cookie via devtools (or the profile's cookie store) for linkedin.com.","Disable cookie-clearing extensions or 'clear cookies on exit' settings for the profile.","Re-login if LinkedIn invalidated the session (e.g. password change, security challenge)."],"exampleFix":"// before: profile cookies were wiped between runs\nrun('linkedin inbox'); // AuthRequiredError: JSESSIONID not found\n\n// after: keep a persistent profile and validate session first\nif (!hasLinkedinSession(profile)) openBrowserForManualLogin(profile);\nrun('linkedin inbox');","handlingStrategy":"type-guard","validationCode":"const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\nif (!cookies.some((c) => c.name === 'JSESSIONID')) {\n  throw new AuthRequiredError('linkedin.com', 'Sign in before running this command.');\n}","typeGuard":"const hasJsessionid = (cookies) => Array.isArray(cookies) && cookies.some((c) => c.name === 'JSESSIONID' && c.value);","tryCatchPattern":"try {\n  await linkedinInbox();\n} catch (e) {\n  if (e instanceof AuthRequiredError && /JSESSIONID/.test(e.message)) {\n    await reloginLinkedin(profile);\n    return linkedinInbox();\n  }\n  throw e;\n}","preventionTips":["Disable 'clear cookies on exit' and cookie-clearing extensions for the automation profile.","Probe for JSESSIONID before long batch jobs and re-login when absent.","Keep the browser profile on disk (not tmpfs) so cookies persist across reboots.","Watch for LinkedIn session invalidation events (password change, new-device challenge) in your ops runbook."],"tags":["authentication","cookies","csrf","linkedin"],"backgroundTag":"session-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}