0

我在基于 cakephp 的 cms 中使用视图缓存,并为前端使用生成缓存视图。前端检查用户是否登录以显示编辑选项。它在没有启用视图缓存的情况下工作,但启用后它会丢失会话。

我已将会话代码放在无缓存标记 (index.ctp) 中,但没有可用的会话

<!--nocache-->
$_SESSION['Auth']['User']['username'];
<!--/nocache-->

使用视图缓存时如何保持登录会话?

4

1 回答 1

1

anwser 是使用 cakephp 会话助手而不是原生 php $_SESSION 变量

<!--nocache-->
$this->session->read('Auth.user.name');
<!--/nocache-->
于 2012-05-03T00:38:02.317 回答