cakePHP“session”不返回会话ID

时间:2010-07-12 16:09:37

标签: cakephp

我正在开发基于cakePHP的Web应用程序。

以下是我的会话处理的core.php设置

  Configure::write('Session.save', 'database');
/**
 * The name of the table used to store CakePHP database sessions.
 *
 * 'Session.save' must be set to 'database' in order to utilize this constant.
 *
 * The table name set here should *not* include any table prefix defined elsewhere.
 */
    Configure::write('Session.table', 'cake_sessions');
/**
 * The DATABASE_CONFIG::$var to use for database session handling.
 *
 * 'Session.save' must be set to 'database' in order to utilize this constant.
 */
    //Configure::write('Session.database', 'default');
    Configure::write('Session.start', true); 
/**
 * The name of CakePHP's session cookie.
 */
    Configure::write('Session.cookie', 'CAKEPHP');
/**
 * Session time out time (in seconds).
 * Actual value depends on 'Security.level' setting.
 */
    Configure::write('Session.timeout', '300');
/**
 * If set to false, sessions are not automatically started.
 */
    Configure::write('Session.start', true);
/**
 * When set to false, HTTP_USER_AGENT will not be checked
 * in the session
 */
    Configure::write('Session.checkAgent', true);
/**
 * The level of CakePHP security. The session timeout time defined
 * in 'Session.timeout' is multiplied according to the settings here.
 * Valid values:
 *
 * 'high'   Session timeout in 'Session.timeout' x 10
 * 'medium' Session timeout in 'Session.timeout' x 100
 * 'low'        Session timeout in 'Session.timeout' x 300
 *
 * CakePHP session IDs are also regenerated between requests if
 * 'Security.level' is set to 'high'.

CakePHP会话ID始终为空。虽然其他会话读/写活动工作得很好。

以下是会话对象。

SessionComponent Object
(
    [__active] => 1
    [__started] => 
    [__bare] => 0
    [valid] => 
    [error] => Array
        (
            [2] => Auth.redirect doesn't exist
        )

    [_userAgent] => 2abebfb51fc971ec64569f7cd415fe0b
    [path] => /
    [lastError] => 2
    [security] => high
    [time] => 1278950154
    [sessionTime] => 1278953154
    [watchKeys] => Array
        (
        )

    [id] => 
    [_log] => 
    [host] =>localhost
    [enabled] => 1
    [cookieLifeTime] => 0
)

正确存储和检索所有其他会话变量,问题是我在任何阶段都没有获得会话ID。

你能帮我解决一下可能出现的问题。

谢谢, Sourabh

3 个答案:

答案 0 :(得分:2)

使用session_id() 我希望它对你有用。

答案 1 :(得分:0)

我有过这样的经历,而且一点也不好。检查是否缺少任何资源。即某些图像,css或js文件可能会丢失,然后Cake会加载丢失的控制器/操作页面,这可能会重置会话。

答案 2 :(得分:0)

参考cakephp session id Empty

尝试使用

开始会话
$this->Session->start();
相关问题