Nice work, Tez. I think colloboration is a great thing, and you had a great initial design. I'm sure it worked for your configuration, which is why a second set of eyes can be useful. Here are some slight modifications I made:
Since I don't have any cookies in use by default, I decided to use a variable reference to the cookie name. When they don't exist by default, I create them. Since you can't reference cookies until next page load, I placed it in a conditional block with your code as the else. I chose to set them for my entire domain, and time out at 1 hour. YMMV.
I thought this was a great idea, so figured it might be cool to make it accessible in any directory, not just the one the file exists in. For some uses different copies of this might be more appropriate though.
Sometimes there won't be a referer. I realized this because I went directly to my test page. In that case I just set the referer to the current page.
I had to check that this session variable was defined before referencing it.
Here's something else I did a little while back, and think it's kinda useful. I have a site where I let different people host DJ mixes, and they each have their own folder. I built a page that dynamically displays and links to the files, but just for their directory. Since I keep enhancing it, distributing the file is a hassle.
Now I just use a simple index file that iterates up through the directory structure until the spot where I keep my constantly changing index file. Unknown directory depths caused me problems, so I wrote this. This also let me keep your file in the top directory rather than copying it everywhere. YMMV of course.
You can grab the zip file here: