cakephp session id为空

时间:2011-04-19 17:06:08

标签: php session cakephp cakephp-1.3

当我这样做时,会话ID为空:pr($this->Session); 我收到了:

SessionComponent Object
(
    [__active] => 1
    [__bare] => 0
    [valid] => 1
    [error] => 
    [_userAgent] => 5343528de22b8a6d25e7fd391692c911
    [path] => /profiles
    [lastError] => 
    [security] => medium
    [time] => 800-452-3639
    [sessionTime] => 800-452-3639
    [cookieLifeTime] => 720000
    [watchKeys] => Array
        (
        )

    [id] => 
    [host] => xyz.org
    [timeout] => 
    [enabled] => 1
)

如何启用会话ID或创建会话ID?

2 个答案:

答案 0 :(得分:5)

如果您真的想要会话ID,则需要启动会话。在您之前的过滤器中尝试这个:

$this->Session->start();
$this->Session->id(session_id());

然后当你pr($this->Session->id());时,你会看到新的会话ID。

答案 1 :(得分:2)

蛋糕被动地照顾 - 你不需要设置它。只需根据需要调用read(),write()。

$this->Session->write('key', $value);

$value = $this->Session->read('key');