Description

C is for cookie, it's good enough for me!

Cookie Monster, as his name suggests, loves cookies.

He loves cookies so much, that he only ever does the following three things:

  • bakes cookies,
  • tastes cookies, and
  • tosses them into the trash.

Conveniently for us, Cookie Monster's cookies happen to take the form of (key,value) string pairs stored in the browser's cache.

Personally, I like to use Cookie Monster to store a user's username and password information in my tool, SyncUThink.

Usage Instructions

If you want to use Cookie Monster in your Procesing sketch too, download the "Processing library" link below and extract the .zip into the "libraries" folder of your Processing installation, same as you would for any other library.

Then, import the cookiemonster library as you would any other library

import org.andrewberman.cookie.*;

and use the following code to get a CookieMonster instance:

CookieMonster monster = new CookieMonster(this);

To "bake" a cookie, you need to specify the cookie's name, value, and expiration time (in days):

monster.bake("My first cookie","Chocolate Chip!",5);

Then, you can "taste" your cookie:

monster.taste("My first cookie"); // Returns "Chocolate Chip".

N.B. Cookie Monster never returns a null String, even if there is no cookie with that name! Instead, he'll return a zero-length String.

Finally, you can toss a cookie into the trash bin (delete it from the browser's cache):

monster.toss("My first cookie"); // I guess it was overcooked!

Downloads

Created with Processing. Built with P5Barebones on March 5 2008.