{"record":{"id":"fc63b37305324549","repo":"jackwener/OpenCLI","slug":"linkedin-jsessionid-cookie-not-found-please-sign","errorCode":null,"errorMessage":"LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.","messagePattern":"LinkedIn JSESSIONID cookie not found\\. Please sign in to LinkedIn in the browser\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linkedin-learning/shared.js","lineNumber":51,"sourceCode":"        },\n      });\n      if (res.status === 401 || res.status === 403) return { authRequired: true, status: res.status };\n      if (!res.ok) return { error: 'HTTP ' + res.status };\n      return { json: await res.json() };\n    } catch (e) {\n      return { error: 'fetch failed: ' + ((e && e.message) || String(e)) };\n    }\n  })()`;\n}\n\nexport async function fetchLinkedInLearningApi(page, url) {\n    await page.goto('https://www.linkedin.com/learning/');\n    await page.wait(3);\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(DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.');\n    }\n    const csrf = jsession.replace(/^\"|\"$/g, '');\n\n    const result = unwrapEvaluateResult(await page.evaluate(buildFetchScript(url, csrf)));\n    if (result?.authRequired) {\n        throw new AuthRequiredError(DOMAIN, `LinkedIn Learning auth failed (HTTP ${result.status ?? ''}).`);\n    }\n    return result;\n}\n","sourceCodeStart":33,"sourceCodeEnd":61,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin-learning/shared.js#L33-L61","documentation":"An AuthRequiredError thrown by fetchLinkedInLearningApi when, after loading linkedin.com/learning/, no JSESSIONID cookie exists in the browser context. JSESSIONID is the session cookie the CLI uses to derive the csrf-token for the in-page API fetch, so its absence means the browser has no authenticated LinkedIn session at all.","triggerScenarios":"The automated/persistent browser profile was never signed in to LinkedIn, the session fully expired and cookies were cleared, the profile directory was reset, or cookies were fetched from a URL context that excludes the session (private window, fresh context).","commonSituations":"Running the CLI on a new machine/container with an empty browser profile, cookie purging by browser settings or cleanup jobs, LinkedIn forcing a full re-login (password change, security challenge), or launching the browser headless with a fresh context.","solutions":["Open the controlled browser, sign in to LinkedIn manually, then re-run the command.","Point the CLI at a persistent browser profile that already has an active LinkedIn session.","Complete any LinkedIn security/2FA challenge that invalidated the session.","Verify cookies exist: page.getCookies({url:'https://www.linkedin.com'}) should include JSESSIONID before calling the API.","Avoid incognito/ephemeral contexts; reuse the same user-data-dir each run."],"exampleFix":"// before\nconst browser = await launch({ headless: true }); // fresh, signed-out context\n// after\nconst browser = await launch({ userDataDir: PROFILE_DIR }); // profile signed in to LinkedIn","handlingStrategy":"try-catch","validationCode":"// verify session cookies exist before invoking any linkedin-learning command\nconst cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\nif (!cookies.some(c => c.name === 'JSESSIONID')) {\n  throw new Error('Not signed in to LinkedIn: open the browser and log in first');\n}","typeGuard":"function hasLinkedInSession(cookies) {\n  return Array.isArray(cookies) && cookies.some(c => c.name === 'JSESSIONID' && !!c.value);\n}","tryCatchPattern":"try {\n  const rows = await trendingOrSearch(page);\n} catch (e) {\n  if (/JSESSIONID cookie not found|AuthRequired/i.test(e.message)) {\n    await interactiveLogin(page); // open visible browser, wait for manual sign-in\n    return trendingOrSearch(page);\n  }\n  throw e;\n}","preventionTips":["Use a persistent browser profile (userDataDir) that stays signed in","Sign in to LinkedIn once before batch runs; re-login when sessions expire","Avoid incognito/ephemeral contexts for LinkedIn automation","Check for security/2FA prompts that invalidate stored sessions","Pre-flight check JSESSIONID presence before long automation runs"],"tags":["auth","session","cookies","linkedin"],"backgroundTag":"auth-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}