私の CakePHP アプリケーションで、別のコントローラーのクラスを使用すると、Session read function エラーが発生します。
example.com/app/getList
うまく
example.com/seconds/parseList
動作します
がexample.com/first/index
、このエラーが発生します:
Fatal error: Call to a member function read() on a non-object in
/example.com/app/Controller/AppController.php on line 468
468 行目は次のとおりです。$list=$this->Session->read('myList');
どうすればこれを修正できますか?
class FirstController extends AppController {
public function index () {
$Seconds = new SecondsController();
$Seconds->parseList();
}
}
class SecondsController extends AppController {
public $helpers = array('Html', 'Session');
public function parseList () {
$output = $this->getList();
return output;
}
}
class AppController extends Controller {
public $uses = array('App', 'Mydata');
var $components = array('Session');
public $helpers = array('Session','Html','Cache');
public function getList () {
$list=$this->Session->read('myList');
return $list;
}
}
example.com/app/getList
編集:うまく機能することに言及する必要があります。このアクションを独立して実行すると、セッションエラーは発生しません。