I’m making a website with html + css + python and I want to make a button where the user can click it but only once. Sort of like a like button on facebook. I don’t have accounts for my users, but I was thinking of using cookies instead (less robust I know, but my website will be simple enough where this is fine).
Do you guys know how I can achieve this?
I’ve done a bunch of googling and trial and error, but nothing seems to work. My counter either doesn’t increment, or it does but the value resets every time I reload the website.
2
Answers
You can use localStorage mechanism:
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
You can create a const an set to true if its active. And you verify each time you click