diff --git a/ansible/roles/horizon/templates/local_settings.j2 b/ansible/roles/horizon/templates/local_settings.j2
index cabaf99afe1fd4362aa365e01794f46ca129a465..c5abb28d32f37c7218a44341e8d8280c59586896 100644
--- a/ansible/roles/horizon/templates/local_settings.j2
+++ b/ansible/roles/horizon/templates/local_settings.j2
@@ -158,6 +158,8 @@ SECRET_KEY='{{ horizon_secret_key }}'
 #    },
 #}
 
+{% if groups['memcached'] | length > 0 and horizon_backend_database | bool == False %}
+SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
 CACHES = {
     'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
@@ -169,6 +171,7 @@ CACHES = {
 {%- endif %}
     }
 }
+{% endif %}
 
 # Send email to the console by default
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'