2013-03-04 60 views
1

我在cakephp應用程序中使用了會話,但它看起來像我設置的會話不在我正在使用的各種控制器之間共享。所以可以說我有在cakephp中的多個控制器中沒有讀取會話

PagesController

 public $components = array('Email', 'Session', 'RequestHandler', 'Cookie'); 
     //this is pages/home 
     public function home(){ 

     $this->Session->write("bunny", "123456"); 
     debug($this->Session->read("bunny")); 
     } 

PersonController

public $components = array('Email', 'Session', 'RequestHandler', 'Cookie'); 
    //this is person/index 
public function index(){ 
     debug($this->Session->read("bunny"); 
} 

當我去到url http://domian.org/person/index,即調試線爲空。不應該打印出「123456」?

+0

您的意思是有'function'在該行'公用分類指數()'? – Dave 2013-03-04 21:09:56

+0

我已經添加了。謝謝。我仍然有相同的錯誤。 – gerl 2013-03-05 14:55:12

+0

它確實調試'null',還是不調試任何東西? – Dave 2013-03-05 17:04:43

回答

0

我不能說它的錯誤,但據我所做的蛋糕php。我發現大多數人在這裏使用php默認函數都面臨同樣的問題。

使用session_start();過濾功能之前或使用ob_clean();過濾功能之前,我想這可能會解決您的問題