2010-07-12 153 views
1

我正在开发基于CakePHP的Web应用程序。cakePHP“会话”没有返回会话ID

这里是我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

+0

什么是你想与你的会话ID做启动会话?你使用它的动机是什么? – mikegreenberg 2010-07-12 16:26:57

+0

我想要做的是将会话ID和某个安全令牌发布到cakePHP操作,并使用会话ID检索会话信息并验证安全令牌。 – Sourabh 2010-07-12 16:39:34

+0

您是否尝试过使用其他会话存储类型之一来查看它是否特定于“DB”会话?我猜你还使用Cake CLI创建了会话数据库表格模式?此外,这有没有正常工作?如果是这样,那么在破产之前你最后采取了哪些措施? – mikegreenberg 2010-07-12 18:58:08

回答

0

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

+0

我检查了没有缺少资源,我认为问题是在其他地方:( – Sourabh 2010-07-13 09:29:25

2

使用session_id() 我希望它能为你工作。