Cookie Crunch

Album Cover: Icky Thump

"You can't be a pimp and a prostitute, too."
White Stripes / Icky Thump

Posted on September 23, 2006 11:21 PM in Web Development
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

One of the disadvantages of rolling your own CMS and not jumping on the WordPress (or other similar available platform) bandwagon is that you more often than not have to get your hands dirty, even when attempting to handle the most trivial things.

Tonight's addition to my blog was a good example of this. I decided to be nice to repeat offenders like Ryan, Sean and Ian and remember their personal information (name, email and website) so the next time they decide to repeat offend, they don't have to do as much work.

Unfortunately, for every action there is an equal and opposite reaction. In saving the work for them, I ended up having to do a bunch of my own. I can't complain, though, because I learned a little bit about JavaScript in the process and finally found a good excuse for installing and using FireBug, which I've heard so many good things about.

I started off by trying to figure out whose blog I visit on a regular basis that remembers my information and most likely isn't powered by WordPress on the backend. The first one that came to mind was Jonathan Snook's, and sure enough he had more than enough JavaScript for me to learn from (read: steal and hack). He had an old cookie getter/setter script from that I was able to use pretty much wholesale, with the exception of minor changes to reflect my domain name.

Past that, though, things started to get very interesting. Because Jonathan is a JavaScript guru, he's made use of several JavaScript libraries like mootools and Prototype to pull off many of the cooler dynamic features of his blog's frontend (check out what he calls fixed comments for an example). However, because I don't need to do anything fancier than setting/getting cookies, I had to take the time to really trace through his code and understand what some of the "convenience" functions of those libraries actually do.

Eventually, after a lot of trial-and-error and familiar debugging in a language I'm not used to being able to debug, I customized the script enough to store personal information in a cookie and fetch it the next time a repeat offender drops by my site (given they allow JavaScript, cookies and other delicious treats).

If you spot anything abnormal, please be sure to let me know. Or, if it works swimmingly, let me know that too. You'll be doing yourself a long-term favor at the same time! :)


Ryan on September 24, 2006 at 4:58 AM:

Ooooo, firebug...


Ian Clifton on September 25, 2006 at 10:02 AM:

I am honored that you spent (probably) hours in order to save me 3-5 seconds ;) I hate dealing with the DIY or Let-Someone-Else-Do-It decisions. Doing it yourself tends to take more time, but you ensure that everything is the way you want it. If you let someone else do it (e.g. use WP), you save time and suffer the consequences. It's the same with working on a car. Most things are easy to fix, they just take time, but it can be easier (and always more expensive) to let a mechanic do it.

I found WordPress to be the closest to "okay" quality for me, but now I continually debate about whether I should make plugins or just create my own CMS from scratch. My main site was a start toward a custom system, but I never had the chance to make a backend, so I end up editting the database directly far too frequently.

Recently, I took a completely different route. I found that Gallery2 and similar systems were overly bloated and excessively slow, so I wanted to make my own system. Then I had some slow access times with the MySQL server, so I decided I'd like to get away from database interaction for that, especially with it being for my MR2 gallery, which can see a sudden jump in hits. I didn't feel like dealing with caching, so I made an ugly script to go through every photo I had, create multiple directories (one for each size) resize every image, create a PHP page with the image and links to other sizes, and create a thumbnail page. The results are like an efficient Frankenstein.


Ian Clifton on September 25, 2006 at 10:16 AM:

P.S. The cookie works.


Ryan on September 28, 2006 at 4:01 PM:

Still working :-)


Sean on October 05, 2006 at 8:55 PM:

Actually it never dawned on me that you *weren't* using WordPress. So I guess that says a lot about the good job you've done on this site. Not that WP is so great, but I've seen more than a few home-brewed blogs that were... well, bad. Good job! :)


Bernie Zimmermann on October 06, 2006 at 5:47 PM:

Thanks, Sean. It's definitely been a work-in-progress. The next step is to batten down the hatches in terms of all the comment spam. I've been able to fight it off manually in a 24-hour range, but I know the Googlebot likes to drop by more frequently than that. I've got some good ideas of what I need to do...the problem is finding the time to actually do it. More on that soon.


Sean on October 09, 2006 at 2:10 AM:

Just a heads-up, but I've been using the stand alone version of Bad Behavior to block comment spam on some of the non-WP sites (created with CakePHP), and it seems to be working well.


Dyllan on October 29, 2011 at 9:55 AM:

Im having issues with the header image in IE


Cuckoldplace on November 02, 2011 at 10:18 AM:
Arielle Thorne on November 07, 2011 at 10:24 AM:

That's a good post! Let me return the Favor. Check out stunning images of the world's most desirable cities. You gotta see these to believe it! And and see where people are finding room deals in a live feed on the website.


Post Comments

If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.


Email Address:



Check this box if you hate spam.