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

183
Views
Set Cloudflare Cookie Based on GET Parameter

I am attempting to set the cloudflare cookie based on the GET Parameter. In this scenario, the GET Parameter is utm_source. Demo URL (worker is currently live): https://ellasbubbles.com/product/cultured-marble-trench-drain-shower-base-36x60-and-30x60/?utm_source=test

I was able to get a head start with this documentation, but cannot seem to get this to work properly. I am using inspect element on chrome to search for cookie and it is unfound - https://www.mikestreety.co.uk/blog/using-cloudflare-workers-to-set-a-cookie-based-on-a-get-parameter-or-path/

addEventListener('fetch', event => {
    event.respondWith(fetchAndApply(event.request))
})

async function fetchAndApply(request) {
    let response = await fetch(request);

    let url = new URL(request.url),
        refer = url.searchParams.get('utm_source');

    response = new Response(response.body, response);

    if(refer) {
        let partnerCookie = `source=${refer}; path=/; domain=https://ellasbubbles.com; secure; HttpOnly; SameSite=None`;
        response.headers.set('Set-Cookie', partnerCookie);
    }

    return response;
}
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!