I’m looking to create a to-do list style webpage but I don’t want users to have to sign in to remember things they’ve ticked off. Very specific use case for this checklist which I won’t get into.
So, let’s say I have a check list like so:
To do:
[✔] Task 1
[ ] Task 2
[ ] Task 3
I’ve ticked Task 1 to say that it’s complete.
Is there a way I can set a cookie so when the user returns, Task 1 is still checked and Task 2 and 3 are still unchecked? This would need to update when Task 2 and Task 3 are inevitably checked or unchecked.
2
Answers
Yes, I managed to solve it with HTML & Javascript:
What this does is to set and get cookies. When a checkbox is clicked, its status is stored in a cookie. When the page is reloaded, the checkboxes statuses are read from the cookies and restored accordingly
If you only need the value in the browser it might be simpler to use localstorage, cookies are intended to be read also on server side.
To set the value:
To read the value: