由于我无法理解的原因,包含客户名称的会话变量将显示一会儿,然后消失。cakephp - 会话变量保持奇怪的行为
在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)
一切行为以同样的方式离奇的变化,它会在视图中显示一段时间,然后消失。不关闭浏览器或重新登录。对该代码进行的随机小改动似乎使其在短时间内恢复生机。
我的答案是答案的问题,我经历,我我只是在等待StackOverflow来允许我设置它。 – 2009-05-18 04:46:30