【发布时间】:2015-06-29 11:27:00
【问题描述】:
设置为数据库时,我无法从 cake php 会话中读取值,它返回 null。
我已经在core.php中设置了
Configure::write('Session', array(
'defaults' => 'database'
));
我已经建立了一个 cakephp 会话表,它将会话数据存储在表中。
我试着读回它
$pid = $this->Session->read('Projectid');
我写的
$this->Session->write('Projectid', key($projects) );
有什么想法吗? 它在使用 php 会话而不是数据库时有效。
数据库sql
CREATE TABLE IF NOT EXISTS `cake_sessions` (
`id` varchar(255) NOT NULL,
`data` text,
`expires` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
更新
我发现如果我删除将列表写入会话的行,它可以读取其他变量。这是一个错误吗?
$projects = $this->Project->find('list', array('fields' => array('id','name')
$this->Session->write('Projects', $projects); //removing this line i can read
【问题讨论】:
标签: php database session cakephp