• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Get Cookie from within a template?

#1
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:
Code:
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?
 
#3
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.
 
#4
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.