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) {
}
}