Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How to send auth cookie from my Chrome extension to my server, when this cookie was set on a website?

When the user logs through my website (running on localhost:3000), my server (running on localhost:8080) sends back a session cookie and this cookie keeps the user logged in.

app.use(cookieSession({
    name: "my-session",
    secret: process.env.SESSION_COOKIE_SECRET,
    maxAge: 24 * 60 * 60 * 1000,
}))

The website has an accompanying Chrome extension and I want to use the same session cookie to authenticate the user, so they don't have to login in 2 different places.

I can get a handle to that cookie inside my Chrome extension:

chrome.cookies.get({"url": "http://localhost:3000", "name": "my-session"}, cookie => {
    console.log("found cookie: " + cookie.value);
    const response = await fetch(
    'http://localhost:8080/users',
    {
      method: "GET",
      credentials: 'include',
    }
  )
})

The cookie was found but it is not sent to my server when the extension makes the request.

This is inside the background script, so I have no document to attach the cookie to. However, I tried setting document.cookie = cookie (and cookie.value) in the popup script and do the same request from there, but the cookie was still missing from the request.

How can I send my website's cookie through my Chrome extension, preferably from the background script?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!