I have a logo that popups on the homepage, after you clicked on it, you can go further on the website (I have got that working splendidly). But when visiting another page and going back to the index page, the animation starts over again.
Is there a way to lock this behind some WordPress-PHP-code or something else?
2
Answers
Thanks for the answer. That was exactly what I was looking for. I've got an if else code together, but to animation has to play twice before it active the else part of the code. Any thoughts on that?
To see in action, here is the site: working example
Best way to approach this would be on the client side (using JavaScript).
Use either
localStorage
orsessionStorage
(depending on the desired result*) to store a variable on the visitors browser. Use this variable to only show the animation once, when the variable is not yet set.See Code Examples Here:
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
(*) The difference between localStorage and sessionStorage:
With
sessionStorage
the data is saved only until the window or tab is closed, while withlocalStorage
the data is persisted until the visitor manually clears his/hers browser cache or until your web app clears the data.