我已经开发了一个简单的Cake应用程序,在完成编码后,我将其上传到my web server,现在它有几个问题(它就像localhost上的一个魅力):
-
setFlash
消息没有't work (I'm使用数据库中的会话,并且cake_sessions
中有一些会话的记录 -
成功登录后,它会再次将我重定向到登录页面 .
-
有时缓存文件就会消失! (我的
tmp
文件夹是可写的)
实际上在登录之前不允许任何操作,但是您应该在登录页面上看到 You are not authorized to access that location.
flash消息,但它只是't appear however if you login with a bad username/password it' ll显示消息( wth?
)
UsersController的登录和注销方法:
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
最后执行的100个查询(来自日志):
SELECT `Session`.`id`, `Session`.`data`, `Session`.`expires` FROM `srv`.`cake_sessions` AS `Session` WHERE `id` = '7orjo8clp192qeie55k6pqro26' LIMIT 1
2 回答
听起来像会话在您的网络服务器上被破坏了 . 检查您的系统时钟 - 如果它的差异超过几分钟,您的会话将很快到期,如果不是立即
确保在用户模型中为登录设置了组件 . 应该是这样的
还要检查以确保正确设置了beforeFilter
edit
这看起来非常类似于你所描述的cakephp login page doesn't go anywhere
考虑到这种奇怪的行为,这也值得一试
https://github.com/cakephp/cakephp/commit/c96e364cbb6ec8dd72dd220836a07ed104d2d50a . 它修复了会话的错误过期