This is not a duplicate question, I cannot find the help I need. I would appreciate advice as to why my following code is not working please.
window.addEventListener("popstate", () => {
if (!cookieExists()) {
showAlerts();
countDownTimer();
document.cookie = `${cookieName}=true;max-age=604800;SameSite=None; Secure`;
}
});
window.history.pushState({}, "", "/");
For context, when the user hits the browser back button, my alerts should show.
Edit: I have updated my code and it still doesn't work. When I click back, it just goes back to the previous page. When I refresh I get an 'oops something went wrong' is there a way to test in the console?