php - 由于缓存,CakePHP Flash 消息未显示

标签 php session cakephp caching

更新:

问题:

Flash 消息未显示。

当我在应用程序中使用事件/停用/添加/编辑功能时,应该会显示 Flash 消息,但不会显示。

当我清除浏览器缓存时,它第一次工作正常(显示 Flash 消息)。 但现在我再次使用“事件/停用/添加/编辑”时,闪存消息未显示。 再次,当我清除浏览器缓存时,它工作正常。

我发现了缓存问题。 但我怎样才能摆脱这个缓存问题。

上一个问题:

我已经找到了缓存问题。

我有一个严重的问题。 CakePHP Flash 消息在一台 PC 上的 Chrome、Fire Fox 浏览器中不显示,但在另一台 PC 上的 Chrome、Fire Fox 浏览器中显示相同的 Flash 消息,而且 JavaScript 在这两种浏览器上都无法显示。

可能出现什么问题?

我在其他 20 台 PC 上检查过,Flash 消息在两个浏览器中都工作正常。

最佳答案

我想你使用缓存助手。

他是这么说的 CakePHP documentation :

Marking Non-Cached Content in Views

There will be times when you don’t want an entire view cached. For example, certain parts of the page may look different whether a user is currently logged in or browsing your site as a guest.

To indicate blocks of content that are not to be cached, wrap them in

<!--nocache--> <!--/nocache-->像这样:

<!--nocache-->
<?php if ($this->Session->check('User.name')): ?>
   Welcome, <?php echo h($this->Session->read('User.name')); ?>.
<?php else: ?>
  <?php echo $this->Html->link('Login', 'users/login'); ?>
<?php endif; ?>
<!--/nocache-->

就您而言:

<!--nocache-->
$this->Session->setFlash('My text here');
<!--/nocache-->

关于php - 由于缓存,CakePHP Flash 消息未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26708399/

相关文章:

php - CakePHP 向表中添加列

PHP Gmail API : can send email but how to add recipient email

php - 如何使用 $_FILES 获取上传进度?

c# - HttpContext.Session 不维护状态

vb.net - 跨选项卡和窗口的 IE8 session 共享

php - cakephp 3 图片上传

php - 在 WooCommerce 订单中显示 ACF 订单自定义字段

php - 如何在 phpStorm 中为整个 PHP 文件自动导入命名空间?

ruby-on-rails - 在不影响正常 session 过期的情况下,在 Rails 中存储持久 session 数据

mysql - 使用 Cakephp 单点登录