如果存在与 CakePHP 应用程序相关的登录问题,是否有需要注意的具体事项?我知道应该在应用程序目录内的 tmp 目录上正确配置权限。会话文件是在
/app/tmp/sessions
下创建的,但用户仍未登录。这似乎非常不一致,即我可以或无法从两个不同的浏览器以同一用户身份登录,可以从一个浏览器登录,但无法从另一个。根本没有特定的模式。
其次,每次部署最新版本时,应用程序仍然呈现旧的缓存数据。尽管清除了
app/tmp/cache
目录。作为解决方法,我在 core.php 中切换调试模式,这似乎清除了缓存。
有专业知识的人可以建议调试问题的最佳方法吗?
谢谢你
下面是缓存和会话处理的代码。 我尝试将会话默认值从“cake”更改为“php”,从那时起它工作正常。 但我不确定这是否会产生不可预见的后果。 所以,我仍然想保留旧的会话处理代码。
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));
/**
* Configure the cache for model and datasource caches. This cache configuration
* is used to store schema descriptions, and table listings in connections.
*/
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));
Configure::write('Session', array(
'defaults' => 'cake',
'timeout' => 86400, // The session will timeout after 2 hours of inactivity
'cookieTimeout' => 86400, // The session cookie will live for at most 24 hours, this does not effect session timeouts
'checkAgent' => false,
'autoRegenerate' => true, // causes the session expiration time to reset on each page load
));
Configure::write('Session', array(
'defaults' => 'cake',
'timeout' => 86400,
'ini' => array(
'session.cookie_path' => str_replace(str_replace(DS, '/', str_replace(ROOT, '', WWW_ROOT).'index.php'), '', $_SERVER['SCRIPT_NAME'])
)
));
上面的会话处理部分已更改为下面的,从那时起就很好了。
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 86400, // The session will timeout after 2 hours of inactivity
'cookieTimeout' => 86400, // The session cookie will live for at most 24 hours, this does not effect session timeouts
'checkAgent' => false,
'autoRegenerate' => true, // causes the session expiration time to reset on each page load
));