i use cakephp-2.5.4 and when i encounter a 404 error, user session killed & user logout from application.
can someone help?
public $components = array (
'Session'
);
i use cakephp-2.5.4 and when i encounter a 404 error, user session killed & user logout from application.
can someone help?
public $components = array (
'Session'
);
Solution:
core.php
Configure::write('Exception.handler','AppErrorHandler::handleException');
bootstrap.php
App::uses('AppErrorHandler', 'Lib');
add AppErrorHandler class in Lib folder with following function
public static function handleException(Exception $exception)
{
if($exception instanceof MissingControllerException ){
return false;
}
$config = Configure::read('Exception');
//self::_log($exception, $config);
$renderer = isset($config['renderer']) ? $config['renderer'] : 'ExceptionRenderer';
if ($renderer !== 'ExceptionRenderer') {
list($plugin, $renderer) = pluginSplit($renderer, true);
App::uses($renderer, $plugin . 'Error');
}
try {
$error = new $renderer($exception);
$error->render();
} catch (Exception $e) {
}
}
To solve this issue:
Please do try this
public $helpers = array('Session', 'Html', 'Form');
public $uses = array('Users','Persons');
public $components = array('Auth' => array(
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email_address'),
'passwordHasher' => array('className' => 'Md5', 'hashType' => 'md5'),
)
),
'loginAction' => array(
'controller' => 'user_masters',
'action' => 'login',
'admin' => true,
),
'loginRedirect' => array(
'controller' => 'user_masters',
'action' => 'dashboard',
'admin' => true,
), 'logoutRedirect' => array(
'controller' => 'user_masters',
'action' => 'login',
'admin' => true,
)), "Cookie", "Session", "Email", 'RequestHandler', 'Security');
Let me know if any issue.