私は CakePHP を初めて使用し、コードで $this->Session->setFlash() を使用しようとしていますが、エラーがあると表示されます: 非オブジェクトでメンバー関数 setFlash() を呼び出します! これが私のコードです
function add(){
if(!empty($this->data)){
if($this->Post->save($this->data)){
$this->Session->setFlash('The post was successfully added');
$this->redirect(array('action'=>'index'));
}else{
$this->Session->setFlash('The post was not saved, please try again');
}
}
}
この問題を解決するにはどうすればよいですか?