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

130
Views
How to delete a cookie if I only know its name's first few characters - with Javascript?

I am creating my own Cookie Consent, and I've experienced a problem with revoking consent - so the user has already allowed consent, but changed their mind and wants to deny them.

When it comes to Google Analytics cookies, there are 2 cookies stored in the browser by GA. One of them is simply called _ga, but the other one is called _ga_ + unique code for every user (for example: _ga_CPQBB2KVM4).

I cannot figure out a way to delete the cookie with the unique code, since I only know it's first 4 characters (I'm using Javascript).

I would be very grateful if you could help me with this!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could just remove the cookie value using:

function removeCookieValue(name) {
    document.cookie = name+'="";-1; path=/';
}

removeCookieValue('_ga')
about 4 years ago · Juan Pablo Isaza Report
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!