At present I am looking to capture expiry date for cookies on the browser.
These are cookies set by others and I can't change it. Just looking to read the cookie and it's expiry.
The following works for Chrome and Edge.
cookieStore.get('myCookie')
.then(cookie => cookie.expiry)
.then(expiry => console.log(expiry))
But this is not supported in Firefox and Safari as mentioned here under browser compatibility.
https://developer.mozilla.org/en-US/docs/Web/API/CookieStore
Are there alternatives, work arounds for Firefox and Safari to achieve the same?
Please advice. Thanks.
There is at least one polyfill library for the cookieStore API : https://github.com/markcellus/cookie-store
I guess a polyfill qualifies as a workaround but note that there is a warning:
EXPERIMENTAL: The Cookie Store API is not a W3C standard yet and the final implementation may differ from the current API of this project.
You may already know it but some cookies are http-only and you may not have access to them from client side javascript.