AnN*_*LaI 5 ssl cakephp cakephp-2.0
在注册期间使用SSL 5页
https://www.mysite.com/step3 - Auth组件登录
在第3步之后,我使用Auth Component创建用户的Session(自动使用户通过Auth组件登录).但是在第5步之后它将重定向到下一页
我使用SSL组件非强制方法将HTTPS更改为HTTP.一切正常,但问题是,一旦我从步骤5(HTTPS)到达欢迎页面,我的Auth组件会话到期.我尝试调试它无法找到任何解决方案.请注意,没有HTTPS,所有步骤和会话都可以正常工作
AppController 类中的代码:
function beforeFilter() {
parent::beforeFilter();
$this->_setupSecurity();}
function _setupSecurity() {
$this->Security->blackHoleCallback = '_badRequest';
if(Configure::read('forceSSL')) {
$this->Security->requireSecure('*'); }
Run Code Online (Sandbox Code Playgroud)
}
/** * 主要的 SecurityComponent 回调。* 处理丢失 SSL 问题和一般错误请求。*/
function _badRequest() {
if(Configure::read('forceSSL') && !$this->RequestHandler->isSSL()) {
$this->_forceSSL();
} else {
$this->cakeError('error400');
}
exit;}
Run Code Online (Sandbox Code Playgroud)
/** * 重定向到同一页面,但使用 https 协议并退出。*/
function _forceSSL() {
$this->redirect('https://' . env('SERVER_NAME') . $this->here);
exit;
Run Code Online (Sandbox Code Playgroud)
}
请点击此链接:也许您会得到解决方案..
| 归档时间: |
|
| 查看次数: |
759 次 |
| 最近记录: |