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

169
Views
Javascript script reading data from deleted cookie (Safari)

I use the following in PHP to delete a cookie:

setcookie("cart", "", time()-3600, "/", ".site.net");

Which works as expected, when I link through to the following page the cookie is not found by PHP and I can confirm it has been deleted using the web inspector in Safari.

However the cookie is still being read on the second page by Javascript as is it was never deleted. I read the cookie in Javascript with:

 var result = document.cookie.match(new RegExp(name + '=([^;]+)'));

Even if I keep reloading the page Javascript loads the cookie (and PHP does not). If I shift reload Javascript stops reading the cookie, so evidently the cookie is being cached and read.

I don't want to turn off caching for the whole page using HTML tags, so is there a way to stop caching of cookies alone, or to stop Javascript using the cache on this page?

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

0

If I delete the cookie via Javascript there is no issue.

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!