Reputation: 1
I'm trying to add a php script to a .tpl file that checks whether or not a cookie has been set:
<?php if (isset($_COOKIE['IA'])) echo "?campaign=333"; if (isset($_COOKIE['IA']) && isset($_COOKIE['Ptag'])) echo "&p=" . $_COOKIE['Ptag'] ;?>
I've tried including the php in {php} code {/php} and also {php} /file/function.php {/php}. I've also tried code.
However, nothing seems to work. can any one help?
Upvotes: 0
Views: 1690
Reputation: 7891
Use the smarty predefined variables: http://www.smarty.net/docsv2/en/language.variables.smarty.tpl
for example:
{if $smarty.cookies.IA}?campaign=333{/if}{if $smarty.cookies.IA && $smarty.cookies.Ptag}&p={$smarty.cookies.Ptag}{/id}
this reveals some security problem such as XSS, so you better validate this params out of the template and pass only valid values to the template - but in general, the way I mentioned is the way to reach the $_COOKIE
global
Upvotes: 1