How do i keep user preference on dark mode with php?

My website has an anchor link which calls a bookmarklet link to change the styles of the page.
How do i save this as a cookie with php?
Dark-

javascript:!function(d){d.head.appendChild(d.createElement(‘style’)).innerText=’#light {display:inline-block;}#dark{display:none;}html,img,video{-webkit-filter:invert(0)hue-rotate(360deg);filter:invert(0)hue-rotate(360deg)}#ilight{display:none;}#idark{display:inline-block;} body,bgimg{background:#373737}’}(document);

Light-

javascript:!function(d){d.head.appendChild(d.createElement(‘style’)).innerText=’#light {display:none;}#dark{display:inline-block;}html,img,video{-webkit-filter:invert(1)hue-rotate(180deg);filter:invert(1)hue-rotate(180deg)}#ilight{display:inline-block;}#idark{display:none;}body,bgimg{background:#000}’}(document);

Take a look at this Treehouse tutorial :slight_smile:
https://blog.teamtreehouse.com/how-to-create-totally-secure-cookies