【发布时间】:2010-07-12 16:09:36
【问题描述】:
我正在开发基于 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。
你能帮我解决什么问题吗?
谢谢, 苏拉布
【问题讨论】:
-
你想用你的会话 ID 做什么?您使用它的动机是什么?
-
我想要做的是,将会话 ID 和一些安全令牌发布到 cakePHP 操作,并使用会话 ID 检索会话信息并验证安全令牌。
-
您是否尝试过使用其他会话存储类型之一来查看它是否特定于“数据库”会话?我假设您还使用 cake CLI 创建了 Sessions DB 表模式?另外,这曾经正常工作吗?如果是这样,您在它崩溃之前采取了哪些最后步骤?
-
是的,我试过“蛋糕”类型,它工作正常,但不给我会话 ID(与设置“数据库”相同)
标签: cakephp