^

Cookie store

2023-05-02

Cookies are getting a bad rap these days. They used to be all the rage. Websites would be like: here you go, have a cookie. And the web browser would respond - free cookies, that's rad!

Well those days are long gone. We can't just enjoy cookies willy nilly anymore. First we need to read the Information super highway billboard informing us of the dangers of cookies, and then we need proceed to accept to eat all the cookies until the browser barfs1 or spend the evening perusing the whole cookie menu and carefully pick and choose which cookies are the most delicious out of the plethora of varieties on offer.

No wonder we have come down with cookie fatigue!

Restoring our fate in cookies

I want to show you that the occasional browser cookie aren't all that bad. We will use these delicacies for good and I know just the use case!

You see, just like the cookies in your cupboard, the cookies in your browser can go bad. It's true! But what happens when a cookie goes bad in your browser, does it give it a tummy ache, diarrhea, unplanned stomach juice expulsion? Of course not! Browsers are much tougher built than our measly little human stomachs! And we will use this to our advantage!

In contrast to the iron stomach of your browser, you are weak! You will suffer if your cupboard cookies have happened to turn bad whilst you were not paying attention. But what if, what if there was a way to make browser cookies work for you, to make sure that cupboard cookies doesn't successfully scheme behind your back to upset your little baby belly?

I'm here to tell you, it can be done!

A plan is formed

Not all browser cookies are made of the same dough. Some really aren't meant to be stored at all and will turn bad within the blink of an eye, at least if you blink rather seldom. These are session cookies. They are of no use to us as they can not be relied upon to keep our cupboard cookies from turning on us.

Until recently the next class of cookies would have easily made the cut for what we have in plan. These class of cookies are the ones defining a Max-Age or Expires directive (just like the ones we're awfully worried about!).

Now it has recently come to my attention that the all-knowing computer gods at 🥽 Inc have decided that these cookies must all be consumed before the reach of 400 days or the browser will eat them for you! This is obviously planned obsolescence of perfectly fine cookies!

This of course raises the question of how long it is reasonable to expect the cupboard cookies to keep in edible condition. I'm happy to inform you that I've spent considerable2 time studying this very question for the benefit of us both! I've come to the conclusion that cookies rarely have an expected shelf life of more than 12 months all-dough there are of course exceptions to this rule of thumb. Therefore the 400 day limit should not interfere with our genius plan to match cupboard cookie expiration dates to browser cookie dittos.

The technical mumbo jumbo

So how do we set a cookie. Well one way is using the lingua franca of web development - javascript, a programming language named to taunt tea drinkers everywhere. This is how we offer the browser a cookie of a common variety in the new world.

const oneHourFromNow = new Date(new Date().getTime() + 60 * 60 * 1000)
const cookieValue = encodeURIComponent("Chocolate Chip Cookies")

document.cookie = `item=${cookieValue}; SameSite=strict; Expires=${oneHourFromNow.toUTCString()}`

The observant reader might have noticed that the cookie in the previous example had a very short shelf life of only 3600 times 1000 milliseconds. This is awfully short for cupboard cookies although sometimes I do eat just bought cookies within an hour of buying them 3.

Introducing: COOKIE

Let me present to you the:

Cupboard Oh-automatic, Oh-how-convenient oK If not-Expired or COOKIE4.

Available at no charge to cookie lovers world wide! Encode the expiration of your cookies with your cookies and make sure to never eat expired cookies again! If it's not in the table below, you either didn't enter it or it should not be consumed.

When you consume your cookies make sure to click the 👄 to mark them as munched! COOKIE will automatically place the cookies with the shortest shelf life at the top for your convenience.

Cookies Expire in

Disclaimer

Functionality requires a browser that is not explicitly configured to discard cookies. This system has been verified to work for a selection of cookies, but cookie-unrelated food items have currently not been approved for entering into COOKIE. Eating of cookies expired or not expired is the sole responsibility of the user. Excessive consumption of cookies may lead to unforeseeable and foreseeable consequences. Always consult your doctor about his and/or her gender pronouns and cookie preferences.

Footnotes:

1

This is technically incorrect (the best kind of incorrect), as a browser is not designed to emulate what in humans is known as barfing.

2

It really was mostly a 🥽-search and a quick perusal of my own cupboard cookies expiration dates.

3

Please don't judge, unless you are an actual judge.

4

I've been told this is not how acronyms are supposed to be constructed, but you know.

map