我在这里遇到一个奇怪的问题。
我正在使用CakePHP 1.3.6&对于IE 6-7-8,它不允许我登录。我正在使用正确的凭据。用记录在日志中测试这些。
没有显示任何身份验证错误。 (如果我使用了错误的凭据,那么它会显示身份验证错误,但是对于正确的凭据,它不会显示任何内容:()
我已经通过将日志记录到error.log文件中来测试auth组件的所有可能性。
我检查了Auth->用户方法。它会填充Auth会话,但即使它没有将我重定向到所需的位置。 我还检查了authLoginurl:它在日志中也是正确的。
我检查了以下可能性,
1)更改了Core.php中的一些设置
- Session.checkAgent设置为false - Security.level设置为低 - Session.start设置为false
2)使用disableCache()进行登录操作,以避免在浏览器中缓存登录数据。
3)退出后我已经破坏了会话。
这是代码,
beforeFilter中的App Controller:
$ this-> Auth-> loginAction = array('controller'=>'users','action'=>'login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'myaccount');
$this->Auth->userScope = array('User.is_active' => '1', 'User.is_verified' => '1');
//$this->referer();
//auth errors //add it
$this->Auth->loginError = "Invalid username or password";
$this->Auth->authError = "Sorry, you must be logged in to visit these pages";
//logout
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
用户控制器beforeFilter():
函数beforeFilter(){
parent::beforeFilter();
$this->Auth->allow(allowed_actions);
}
Thnaks, 维杰
答案 0 :(得分:4)
我遇到了同样的问题,这是一个不同的蛋糕版本,但也许这个解决方案会有所帮助。
在配置中,我创建了一个my_session.php
文件,其中包含以下值:
ini_restore('session.referer_check');
ini_set('session.use_trans_sid', 0);
ini_set('session.name', Configure::read('Session.cookie'));
ini_set('session.cookie_lifetime', 0);
// Cookie path is now '/' even if you app is within a sub
// directory on the domain
$this->path = '/';
ini_set('session.cookie_path', $this->path);
ini_set('session.cookie_domain', env('HTTP_BASE'));
重要的部分是$this->path
值,会话现在可用于整个域。
在会话core.php
中添加:
Configure::write('Session.save', 'my_session');
希望这有帮助!