Get Cookie from within a template?


Is it possible to check for a cookie from within a template? The cookie is set based on visitor preferences and I just want to check if it exists.

In PHP I would write:
if(isset($_COOKIE["preferences"])) {
// insert javascript code here
} else {
// insert different javascript code here

If it is not possible to access cookies within the template could anyone point to an easy way to do it without editing files that I might overwrite when I upgrade?
I want to include different javascript based on visitor preferences (the javascript in question being a Google ad).

I don't think I can do that using the javascript method of getting cookies without messing around with the ad code which I'm not supposed to do.
I think I've fixed it by using a callback to a php file. It was probably also possible in javascript but I'm not all that good at that.
Top Bottom