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

已将Session 组件包含在

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

1 回答 1

0

尝试

public $components = array('Session');   

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

   print "<br><pre>";       
   print_r($this->Session->read('text'));
   print "<br><pre>";
于 2013-09-04T05:25:37.413 回答