Hacker News new | ask | show | jobs
by adaml_623 964 days ago
Regarding the local storage Vs server side defaults I don't understand why you wouldn't use a web cookie to store the on/off state? Am I missing something
2 comments

A lot of people have forgotten that cookies aren't just for session id and can store anything. The browser also sends them all in the initial GET request. So yes you're right, it could have been done server-side for the 2nd visit.

Also, because of cookie banners, they got a bad reputation even though most countries allow you to store non personal data. Even just data that is necessary for the functionality of the website doesn't need permission.

That requires a dynamic backend, though. A lot of people use static site generators for their blogs these days. Otherwise you're absolutely right and this is a perfect use for a cookie.
Setting a cookie is a good idea—I honestly just didn't think of it. I created a todo for myself to explore that whenever I can get around to it.