2

我想在我的 ExpressionEngine 模板中使用一些存储的 cookie 值,而不使用任何 PHP。

我当前的模板代码

{exp:channel:entries channel="favorites" category="<?php echo $COOKIE['favorite']?>"}
{title}
{/exp:channel:entries}

这很丑陋,并且在负载下表现不佳。有什么建议么?也许是一个插件?

4

1 回答 1

5

您必须在 EE 中使用 Functions 类中的 set_cookie() 方法设置 cookie。

http://expressionengine.com/user_guide/development/reference/functions.html#set-cookie-name-string-value-string-expire-int

$this->EE->functions->set_cookie('your_cookie_name', 'some_value', 3600 * 24) // Set a cookie that expires in 1 day

$this->EE->input->cookie('your_cookie_name'); // returns 'some_value';

来自 Devot:ee 的 EE 附加组件

http://devot-ee.com/add-ons/cookies

于 2012-11-05T23:03:09.690 回答