show error form when db is down and using CDbHttpSession

I want to show an error form when my database is not available. However I am using CDbHttpSession defined in main.php as:

'session' => array( 'class'=>'CDbHttpSession', 'sessionTableName' => 'internalsessions', 'timeout' => 86400, 'connectionID' => 'db', 'cookieMode' => 'only', 'autoStart' => false, ),

The error handler is defined in main.php as:

'errorHandler'=>array( 'errorAction'=>'site/error', ),

What seems to happen is that when there’s no database connection Yii tries to render the error form but whilst rendering it first hits the session, tries to write to the database and encounters an Exception there. Thus my error form never renders completely. Anyone know a trick around this?



Sorry I’m late but in case someone needs the answer:

You could create an extension of the original class:

class MyHttpSession extends CDbHttpSession


protected function getDbConnection()


// Modify here the way it handles the connection to display a different error that you wish.



And then in the config file:

  1. Import this class

‘import’ => array(



  1. Set this class to be used for session storage.

‘session’ => array( ‘class’=>‘MyHttpSession’, ‘sessionTableName’ => ‘internalsessions’, ‘timeout’ => 86400, ‘connectionID’ => ‘db’, ‘cookieMode’ => ‘only’, ‘autoStart’ => false, ),

Hope you can understand what I mean!