在cakephp中的多个控制器中不会读取会话

时间:2013-03-04 20:03:32

标签: session cakephp cakephp-2.1

我在cakephp应用程序中使用Sessions,但看起来我设置的会话不在我正在使用的各种控制器之间共享。所以我要说我有

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");
 }

当我转到网址http://domian.org/person/index时,该调试行为空。不应该打印出“123456”吗?

1 个答案:

答案 0 :(得分:0)

我不能说它的bug但是我已经在蛋糕php上工作了。我发现大多数人都面临同样的问题,在这里使用php默认功能。

在过滤功能之前使用session_start();或在过滤功能之前使用ob_clean();我认为这可能会解决您的问题

相关问题