出于我无法理解的原因,包含客户姓名的会话变量会出现一小会儿,然后消失。
在 app_controller.php 中: beforeFilter()
if (isset($_SESSION['customer_name']) == false ||
strlen($_SESSION['customer_name']) == 0)
{
$customer = $this->Customer->read(null, $auth['User']['customer_id']);
$name = $customer['Customer']['fname'] . " " . $customer['Customer']['lname'];
$this->Session->write('customer_name', $name);
$this->set('name', $this->Session->read('customer_name'));
}
else
{
$this->set('name', $this->Session->read('customer_name'));
}
我尝试过检查会话是否设置的变体,例如
if ($this->Session->check('customer_name') == false)
一切都以同样奇怪的方式表现,它会在视图中显示一会儿,然后消失。关闭浏览器或再次登录时不会回来。对该代码的随机小改动似乎可以在短时间内使其恢复活力。