获取cookie值并在ExpressionEngine模板中使用它

Vic*_*rez 2 expressionengine

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

我目前的模板代码

{exp:channel:entries channel="favorites" category="<?php echo $COOKIE['favorite']?>"}
{title}
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)

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

Jus*_*ell 5

您必须使用Functions类中的set_cookie()方法在EE中设置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';
Run Code Online (Sandbox Code Playgroud)

来自Devot的EE附加组件:ee

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