私は Cakephp セッションで非常に奇妙な問題を経験しています。コントローラーに電子メールコードを含めていない場合、セッションは機能しています。セッションが設定され、ビューで使用できるようになります。
$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.
しかし、電子メール コードを含めてセッションを設定すると、セッションは設定されず、ビューでも使用できません。
//$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の何が問題なのかを誰かが理解してもらえますか??