Third Party Cookie Expiry Date

75 views Asked by At

I am trying to programmatically retrieve the expiry date of a third-party cookie using JavaScript. While I can view the expiry time in the browser's DevTools (see screenshot https://i.stack.imgur.com/BW072.png, I'm unable to figure out how to obtain this information through code.

I've attempted to use "document.cookie", but it only returns the value of the third-party cookie, not the expiry date. Is there a way to fetch the expiry date using JavaScript?

I would greatly appreciate any insights or code snippets that could help me achieve this. Thank you in advance!

1

There are 1 answers

1
AudioBubble On
fetch('https://example.com') // Replace with the URL where the third-party cookie is set
  .then(response => {
    console.log(response.headers.get('Set-Cookie'));
    // Parse the Set-Cookie header to extract expiry date information
    // Remember, not all servers provide this information in the header
  })
  .catch(error => console.error(error));