Archive - January, 2009

Signed Cookies in PHP

I saw the Signed Cookies in Django Middleware and looked around to see if something like that had been done in PHP. I didn’t see anything immediately – perhaps some of the frameworks have it buried in their docs somewhere?

So I put together a small class that handles cookie signing, and verification, for PHP.

It’s nothing very serious, and could probably be vastly improved – but I like going the route of “absolutely minimal”, so that you could quickly grab the concepts and put them to practice in whatever code-base you’re working on.

UPDATE:
In the time since writing this, I seem to have misplaced the specific portion of code that I had laying around. In the mean time, I highly suggest checking out this answer about signed cookies at StackOverflow, which should cover all of the basics to get you started, should you choose to take that route.