How to use cookies w/ JavaScript

I recently had the need to keep some client-side settings persistent so I whipped up a very basic set of functions to both set and read cookies. Cookies are very handy when you aren't working with a single-sign-on environment (where user preferences are very easy to store in a database) but still need to keep some user data/settings. In this example there is a div element that can be shown/hidden and that selection remains persistent between browser sessions.

In reality I had to store quite a bit more data than in the example and also enable dynamic (JavaScript powered) CSS switching to further enhance the user experience but I wanted to keep this example nice and succinct. There is a lot you can do with JavaScript in conjunction with cookies to give users a custom feel on your site. If you have examples/stories of your experience(s) with using cookies in your application I'd love to hear about them in the comments!