I'm having this issue.
I'm working on a courses webpage where I have loading animation that is now only shown first time when a user visits the site. I'm changing it now so the cookie that holds the animation is reset after 1 hour.
The issues is that the cookie doesn't reset. Time to Live was set and it works but the cookie doesn't clear itself after an hour. Here is the code that is used to set the cookie timeToLive and value
if(localStorage.getItem("loader-cookie")) {
document.getElementById("application-loader").classList.remove("is-active");
} else {
document.getElementById("application-loader").classList.add("is-active");
// If loader-cookie expired we add a new one
const storageItem = {
value: "loader-cookie",
timeToLive: Date.now() / 1000 + 3600,
};
localStorage.setItem("loader-cookie", JSON.stringify(storageItem));
}
Let me know if more info is needed for the problem.
Thank you