How can I implement a cookie based saving system with Javascript?

For my Harlowe based game I want to be able to have the game automatically save itself to a cookie for when I publish the game to Kongregate. Is there a preexisting Javascript code for this?