I designed 2 themes for my website (daymode and nightmode) but when i refresh the page, it doesn't remember the last mode. How can i set a cookie to remember the last selected theme ? Here's the code :
HTML
<body class="daymode">
<button data-switch-contrast aria-hidden>Switch Colors</button>
</body>
CSS
.daymode {
//daymode content
}
.nightmode {
//nightmode content
}
JS
document.querySelector('[data-switch-contrast]').addEventListener('click', function() {
document.body.classList.toggle('nightmode');
});