未定义的变量:CakeSp 2.0中的_SESSION [APP \ Controller \ UsersController.php

时间:2013-09-03 21:54:46

标签: cakephp

Undefined variable: _SESSION [APP\Controller\UsersController.php in cakephp 2.0

已将会话组件纳入

UsersController var $components = array('Session', 'Cookie');

代码就是:

if(!empty($id))
{               
   print "<br><pre>";       
   print_r($_SESSION['text']);
   print "<br><pre>";
   print_r($this->Session->read("captchatext"));
   die;     
}  
else
{
   $_SESSION['text'] = "jjsssssjj";
   $this->Session->write("captchatext", "ddddddssssssssssdddd");
   print "ddddddssssssssssdddd";
}

1 个答案:

答案 0 :(得分:0)

尝试

public $components = array('Session');   

为什么不使用cakephp语法来读取会话,如:

   print "<br><pre>";       
   print_r($this->Session->read('text'));
   print "<br><pre>";