我有时会遇到CakePhp。
1 - 当用户登录时,我会在Session中保存用户名,并且还会执行一些缓存逻辑以避免一些无用的查询:
$cacheTime = '24h';
$cacheKey = md5(self::SITE_NAME . ' - ' . $login);
$cachedLogin = Cache::read($cacheKey, $cacheTime);
if ($cachedLogin) {
$this->log('Already logged in : ' . $cachedLogin, 'curl');
$this->Session->write('user_logged', 1);
$this->Session->write('username', $cachedLogin);
$this->redirect(array('controller' => 'interactions', 'action' => 'pronostics', '?' => array('disclaimer_popup' => 1)));
}
然后,当他们点击断开连接时,有时候,我没有在会话中设置用户名:
if ($this->Session) {
$cacheKey = md5(self::SITE_NAME . ' - ' . $this->Session->read('username'));
$cacheTime = '24h';
Cache::delete($cacheKey, $cacheTime);
$this->log('Logout : ' . $this->Session->read('username'), 'curl');
$this->Session->destroy();
}
当我查看日志时,有时我没有设置用户名(例如,我得到:Logout :
而不是Logout : kamelmah
)
2 - 我的付款控制器也遇到同样的问题:我使用Paypal让用户订阅我的服务。 95%的交易一切顺利,但对于5%的交易,我在流程的开始和结束之间丢失了数据。 开始是选择用户名,电子邮件,密码;我在Session中设置了它。付款完成后,我使用存储在会话中的信息在db中创建条目但我有5%的问题,因为存储在会话中的数据丢失了,我不知道为什么。
这些问题经常发生在你身上吗?你做了什么修复它?
感谢。