在 prestashop 1.5 中,不推荐使用 global。
在 cookie 中设置一些东西:
在控制器中:
$this->context->cookie->__set($key,$value);
其他文件:
$context = Context::getContext();
$context->cookie->__set($key,$value);
您可以通过以下方式访问您的价值:
在控制器中
$this->context->cookie->key
其他文件:
$context = Context::getContext();
$context->cookie->key;
Prestashop 不使用 $_SESSSION,因此您无法访问$smarty.session.key
您必须将变量分配给 smarty
在控制器中:
$this->context->smarty->assign(array('key' => $this->context->cookie->key));
其他文件:
$context = Context::getContext();
$context->smarty->assign(array('key' => $context->cookie->key));