Cakephp Auto Accompaniment Expires After Using SSL Unmatched Method

After step 3, I create a user session using Auth Component (automatically forcing the user to register using the Auth component). But after step5, it will redirect to the next page

http://www.mysite.com/welcome

I use the laid-back method of SSL components to change HTTPS to HTTP . Everything works fine, but the problem is that after I reach the welcome page from step 5 (HTTPS), my Auth component session expires. I try to debug it failed to find a solution. Please note that without HTTPS all steps and sessions work fine

+5
source share
2 answers

Code in the AppController class:

function beforeFilter() {
parent::beforeFilter();
$this->_setupSecurity();}

function _setupSecurity() {
$this->Security->blackHoleCallback = '_badRequest';
if(Configure::read('forceSSL')) {
    $this->Security->requireSecure('*');    }

}

/ ** * The main SecurityComponent callback. * Handles both missing SSL problems and general bad requests. * /

function _badRequest() {
if(Configure::read('forceSSL') && !$this->RequestHandler->isSSL()) {
    $this->_forceSSL();
} else {
    $this->cakeError('error400');
}
exit;}

/ ** * Redirect to the same page, but with https protocol and exit. * /

function _forceSSL() {
$this->redirect('https://' . env('SERVER_NAME') . $this->here);
exit;

}

Follow this link: Maybe you will get your solution.

fooobar.com/questions/1124375 / ...

+2

Cakephp 2.0,

/Cake//Datasource/

CakeSession.php

if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS'))
{
        $sessionConfig['ini']['session.cookie_secure'] = 1; // Just comment this line and try it will works
}
+3

All Articles