【问题标题】:Session is not read in multiple controllers in cakephpcakephp 的多个控制器中未读取会话
【发布时间】:2013-03-04 20:03:31
【问题描述】:

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

页面控制器

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

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

人员控制器

  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”吗?

【问题讨论】:

  • 您的意思是在public index() 行中有function 吗?
  • 我已经添加了。谢谢。我仍然有同样的错误。
  • 它实际上是在调试“null”,还是没有调试任何东西?

标签: session cakephp cakephp-2.1


【解决方案1】:

我不能说它是错误,但就我在蛋糕 php 上的工作而言。我发现大多数人都面临同样的问题,在这里使用 php 默认函数。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 2011-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多