Skip to content

Instantly share code, notes, and snippets.

@jkereako
Last active August 29, 2015 14:18
Show Gist options
  • Save jkereako/5df6d93f9d11a7b4f6c9 to your computer and use it in GitHub Desktop.
Save jkereako/5df6d93f9d11a7b4f6c9 to your computer and use it in GitHub Desktop.
Cookie class
@jkereako
Copy link
Author

Description

This code provides an an object-oriented way to deal with browser cookies. This is nothing revolutionary and I'm certain you've seen several other implementations elsewhere.

The backstory is that I recently started using CoffeeScript after having known about it since 2009. I didn't adopt it then because I was completely unfamiliar with JavaScript.

Many years and JavaScript syntax errors later, I revisit CoffeeScript and was amazed by how fast and easy I can develop complex JavaScript routines. I'm doing all sorts of garbage in JavaScript that I would never attempt before because I could not understand it.

Usage

var cookie = new Cookie("my_cookie", {"last_visit": new Date(), "name": "John Doe"}, 30)
cookie.save()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment