{"record":{"id":"7bed2e0e78c5f147","repo":"jackwener/OpenCLI","slug":"linkedin-jsessionid-cookie-not-found-please-sign-7bed2e","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":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-search.js","lineNumber":147,"sourceCode":"  strategy: Strategy.UI,\n  browser: true,\n  args: [\n    { name: 'keywords', type: 'string', required: true, positional: true, help: 'People search keywords, e.g. \"quality manager food manufacturing\"' },\n    { name: 'limit', type: 'number', default: 25, help: 'Maximum leads to return (1-500, fetched 25 per request)' },\n  ],\n  columns: ['rank', 'name', 'title', 'company', 'location', 'degree', 'profile_url', 'lead_url', 'recipient_urn'],\n  func: async (page, args) => {\n    if (!page) throw new CommandExecutionError('Browser session required for linkedin salesnav-search');\n    const keywords = requireStringArg(args, 'keywords', '--keywords');\n    const limit = parseLimit(args.limit);\n\n    await page.goto(SALES_HOME);\n    await page.wait(6);\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    const leads = [];\n    const seen = new Set();\n    for (let start = 0; leads.length < limit && start < 2000; start += PAGE_SIZE) {\n      const result = unwrapEvaluateResult(await page.evaluate(fetchLeadSearchScript(leadSearchUrl(keywords, start), csrf)));\n      const json = requireLeadSearchResult(result);\n      const pageLeads = parseLeads(json);\n      if (pageLeads.length === 0) break;\n      for (const lead of pageLeads) {\n        const key = lead.profile_url || lead.name.toLowerCase();\n        if (seen.has(key)) continue;\n        seen.add(key);\n        leads.push(lead);\n      }\n      await page.wait(1);\n    }","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-search.js#L129-L165","documentation":"Thrown in clis/linkedin/salesnav-search.js:147 after navigating to Sales Navigator home and reading cookies for https://www.linkedin.com: no cookie named JSESSIONID was present. JSESSIONID is required to derive the csrf-token header for LinkedIn REST API calls. Its absence means the browser is not signed in to LinkedIn (or the session cookie was not scoped to the www domain), so the search cannot authenticate. The error is raised as AuthRequiredError, signaling the user must log in.","triggerScenarios":"page.getCookies() returns no JSESSIONID because the browser profile is logged out; cookies are scoped to a different domain/subdomain than https://www.linkedin.com; navigating to /sales/ redirected to a login page; cookie expiry or a LinkedIn logout wiping the session.","commonSituations":"Fresh automation browser profile with no saved LinkedIn login; session expired after LinkedIn's security logout; running from a region/IP that forces re-authentication; using a profile where cookies are stored under linkedin.com without www and the lookup URL filter misses them.","solutions":["Sign in to LinkedIn in the automation browser (run the platform's login flow) and retry the command.","Verify the session by loading https://www.linkedin.com/feed/ and confirming you are not redirected to the login page.","Check cookies manually for a www.linkedin.com JSESSIONID (document.cookie or devtools) to rule out domain-scoping mismatches.","If the profile persists cookies but the session keeps dropping, re-authenticate and avoid sharing the profile across concurrent automation runs."],"exampleFix":"// before (assume cookie exists)\nconst csrf = jsession.replace(/^\"|\"$/g, '');\n// after (check login state before reading cookies)\nawait page.goto('https://www.linkedin.com/feed/');\nif (/login/.test(page.url())) { await interactiveLogin(page); }\nconst cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\nconst jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\nif (!jsession) throw new AuthRequiredError('www.linkedin.com', 'sign in first');","handlingStrategy":"validation","validationCode":"// Verify login state before the API flow:\nawait page.goto('https://www.linkedin.com/feed/');\nif (/\\/login|checkpoint/.test(page.url())) {\n  throw new AuthRequiredError('www.linkedin.com', 'Sign in to LinkedIn before running salesnav-search');\n}\nconst hasJsession = (await page.getCookies({ url: 'https://www.linkedin.com' }))\n  .some((c) => c.name === 'JSESSIONID' && c.value);\nif (!hasJsession) throw new AuthRequiredError('www.linkedin.com', 'JSESSIONID missing; log in again');","typeGuard":"function hasLinkedInSession(cookies) {\n  return Array.isArray(cookies) && cookies.some(\n    (c) => c.name === 'JSESSIONID' && typeof c.value === 'string' && c.value.length > 0\n  );\n}","tryCatchPattern":"try {\n  const leads = await run('linkedin salesnav-search', [keywords]);\n} catch (err) {\n  if (err instanceof AuthRequiredError) {\n    await interactiveLogin(page); // open login flow, wait for user/2FA\n    return run('linkedin salesnav-search', [keywords]);\n  }\n  throw err;\n}","preventionTips":["Use a persistent browser profile that keeps the LinkedIn session across runs, and re-login proactively when sessions expire.","Check for JSESSIONID (or a logged-in marker) at pipeline start and authenticate before batch operations.","Avoid sharing one automation profile across concurrent jobs, which can trigger LinkedIn security logouts."],"tags":["linkedin","authentication","cookie","jsessionid","csrf"],"backgroundTag":"session-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}