diff --git a/index.php b/index.php
index a2caa75..0166738 100644
--- a/index.php
+++ b/index.php
@@ -383,8 +383,6 @@ if ( $ini->variable( 'SiteAccessSettings', 'CheckValidity' ) === 'true' )
 
 if ( $sessionRequired )
 {
-    $dbRequired = true;
-
     // Check if this should be run in a cronjob
     if ( $ini->variable( 'Session', 'BasketCleanup' ) !== 'cronjob' )
     {
@@ -419,23 +417,22 @@ if ( $sessionRequired )
     }
 
     eZSession::addCallback( 'regenerate_post', 'eZSessionBasketRegenerate');
+
+    if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' )
+        eZSession::start();
+    else
+        eZSession::lazyStart();
+
+    // let session specify if db is required
+    $dbRequired = eZSession::getHandlerInstance()->dbRequired();
 }
 
-$db = false;
-if ( $dbRequired )
+
+if ( $dbRequired && !eZDB::instance()->isConnected() )
 {
-    $db = eZDB::instance();
-    if ( $sessionRequired )
-    {
-        if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' )
-            eZSession::start();
-        else
-            eZSession::lazyStart();
-    }
-    else if ( !$db->isConnected() )
-        $warningList[] = array( 'error' => array( 'type' => 'kernel',
-                                                  'number' => eZError::KERNEL_NO_DB_CONNECTION ),
-                                'text' => 'No database connection could be made, the system might not behave properly.' );
+    $warningList[] = array( 'error' => array( 'type' => 'kernel',
+                                              'number' => eZError::KERNEL_NO_DB_CONNECTION ),
+                            'text' => 'No database connection could be made, the system might not behave properly.' );
 }
 
 // eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
@@ -885,8 +882,9 @@ if ( $module->exitStatus() == eZModule::STATUS_REDIRECT )
         }
 
         $tpl = eZTemplate::factory();
-        if ( count( $warningList ) == 0 )
+        if ( !isset( $warningList[0] ) )
             $warningList = false;
+
         $tpl->setVariable( 'site', $site );
         $tpl->setVariable( 'warning_list', $warningList );
         $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) );
@@ -901,9 +899,8 @@ if ( $module->exitStatus() == eZModule::STATUS_REDIRECT )
 }
 
 // Store the last URI for access history for login redirection
-// Only if database is connected, user has session and only if there was no error or no redirects happen
+// Only if user has session and only if there was no error or no redirects happen
 if ( eZSession::hasStarted() &&
-    is_object( $db ) && $db->isConnected() &&
     $module->exitStatus() == eZModule::STATUS_OK )
 {
     $currentURI = $completeRequestedURI;
@@ -1041,8 +1038,9 @@ if ( $show_page_layout )
 
     $tpl->setVariable( "access_type", $access );
 
-    if ( count( $warningList ) == 0 )
+    if ( !isset( $warningList[0] ) )
         $warningList = false;
+
     $tpl->setVariable( 'warning_list', $warningList );
 
     $resource = "design:";
diff --git a/lib/ezsession/classes/ezpsessionhandler.php b/lib/ezsession/classes/ezpsessionhandler.php
index 1e34134..0172ad9 100644
--- a/lib/ezsession/classes/ezpsessionhandler.php
+++ b/lib/ezsession/classes/ezpsessionhandler.php
@@ -173,5 +173,15 @@ abstract class ezpSessionHandler
     {
         return true;
     }
+
+    /**
+     * Signals that handler requires db instance
+     *
+     * @return bool
+     */
+    static public function dbRequired()
+    {
+        return true;
+    }
 }
 ?>
diff --git a/lib/ezsession/classes/ezpsessionhandlerphp.php b/lib/ezsession/classes/ezpsessionhandlerphp.php
index b0e1cc7..e10ebcb 100644
--- a/lib/ezsession/classes/ezpsessionhandlerphp.php
+++ b/lib/ezsession/classes/ezpsessionhandlerphp.php
@@ -115,5 +115,12 @@ class ezpSessionHandlerPHP extends ezpSessionHandler
         return false;
     }
 
+   /**
+     * reimp (this handler does not use db)
+     */
+    static public function dbRequired()
+    {
+        return false;
+    }
 }
 ?>
