How do you get a cookie in a radiant extension

I have written an extension that gives me a few customer tags for
generating download links.

In my layout I use javascript to set a cookie according to what page
referred the user to my site.

If that user later clicks over to the download page I want to customize
the download link according to how (and if) the cookie is set.

Does anybody know how to retrieve a cookie from within a tag definition
block?