我正在通过Cakephp会话传递一个非常奇怪的问题。如果我不在控制器中包含电子邮件代码,则会话正在运行。会话将设置,它将在View中显示。
$this->Email->to = 'email@example.com';
$this->Email->subject = 'Website request';
$this->Email->send($this->data['Contact']['message']);
$this->Session->write('success','After Sending Email.');
// This will not save session.
但如果我包含电子邮件代码并设置会话,它将不会设置会话,也不会在View中提供。
//$this->Email->to = 'email@example.com';
//$this->Email->subject = 'Website request';
//$this->Email->send($this->data['Contact']['message']);
$this->Session->write('success','After Sending Email.');
// This will save session as email code is commented
现在真正的问题来了。当我在发送电子邮件之前设置会话时,它将在视图中可用,但如果我在发送电子邮件后设置会话,则它在视图文件中不可用。请检查以下代码块。
$this->Session->write('success','After Sending Email.');
$this->Email->to = 'email@example.com';
$this->Email->subject = 'Website request';
$this->Email->send($this->data['Contact']['message']);
// This will save session as its set before sending email
有人可以找出My Code或CakePHP出了什么问题吗?