在我的CakePHP應用程序中,當我使用另一個控制器的類時,出現Session讀取函數錯誤。CakePHP會話組件錯誤
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
運作良好。當我獨立運行此操作時,它不會給出會話錯誤。
被AUTO_SESSION設置爲/app/config/core.php假? – 2012-07-24 12:46:38