I currently have an issue with setting a cookie in a block of php code that is in a .tpl smarty template class.
In the .tpl class I have somethng like :
{php}
setcookie("school", "test");
{/php}
School: { $smarty.cookies.school }
However this does not print out anything. I know the php setcookie call works when its in a .php file alone, since I’ve tested that, but can’t get it to work with the php snippet of code is in a .tpl class.
Any Advice Appreciated,
D
It’s because $_COOKIE superglobal is updated only on page refresh, not after using
setcookie()Make sure you are using
SmartyBC.class.phpnotSmarty.class.phpbecause{php}{/php}will not work using Smarty.class.php.Also remember to set
$php_handlingproperty to SMARTY_PHP_ALLOW.More info http://www.smarty.net/docsv2/en/variable.php.handling.tpl