diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml
index 84279ea2f51a8d99cf82ae83c91ba53b8f086f68..00fd354e5fc64008808cb0c29a08dc2d0658f76c 100644
--- a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml
+++ b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml
@@ -1,11 +1,3 @@
-<?
-  if($loggedin = $this->auth()->isLoggedIn()) {
-    $user_id = $loggedin->id;
-    $loggedin = true;
-  } else {
-    $user_id = false;
-  }
-?>
 <div class="span-13" vocab="http://schema.org/" resource="#record" typeof="<?=$this->driver->getSchemaOrgFormats()?> Product">
   <h1 property="name"><?=$this->escapeHtml($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection())?></h1>
 
diff --git a/themes/blueprint/templates/layout/layout.phtml b/themes/blueprint/templates/layout/layout.phtml
index 5d0f99455f3b49f21d4e0c080b860b7c25fa05f2..f96416f5e055e46f6c56c4fb13ea34ec85074979 100644
--- a/themes/blueprint/templates/layout/layout.phtml
+++ b/themes/blueprint/templates/layout/layout.phtml
@@ -58,6 +58,15 @@
                 );
             }
             $this->headScript()->appendScript($this->jsTranslations()->getScript());
+            if($loggedin = $this->auth()->isLoggedIn()) {
+                $user_id = $loggedin->id;
+                $loggedin = true;
+            } else {
+                $user_id = false;
+            }
+            $this->headScript()->appendScript(
+                'var userIsLoggedIn = ' . ($loggedin ? 'true' : 'false') . ';'
+            );
         }
         if ($feedback) {
             $this->headScript()->appendFile("jquery.tabSlideOut.v2.0.js");
diff --git a/themes/bootstrap3/templates/RecordDriver/SolrDefault/core.phtml b/themes/bootstrap3/templates/RecordDriver/SolrDefault/core.phtml
index 927ce810f6322729008cbcd8bd609072560a2b19..98b3841ca286a942a06c638f0901589b45338810 100644
--- a/themes/bootstrap3/templates/RecordDriver/SolrDefault/core.phtml
+++ b/themes/bootstrap3/templates/RecordDriver/SolrDefault/core.phtml
@@ -1,14 +1,3 @@
-<?
-  if($loggedin = $this->auth()->isLoggedIn()) {
-    $user_id = $loggedin->id;
-    $loggedin = true;
-  } else {
-    $user_id = false;
-  }
-?>
-<script>
-  var userIsLoggedIn = <?=$loggedin ? 'true' : 'false' ?>;
-</script>
 <div class="row" vocab="http://schema.org/" resource="#record" typeof="<?=$this->driver->getSchemaOrgFormats()?> Product">
   <div class="col-sm-3">
     <div class="text-center">
diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml
index 154317b0ff87daaa2912be86e9733ce25125d28d..f5633b7b0a0e6ba1cc6a0c0bceec07bf884a78c5 100644
--- a/themes/bootstrap3/templates/layout/layout.phtml
+++ b/themes/bootstrap3/templates/layout/layout.phtml
@@ -63,6 +63,15 @@
           );
         }
         $this->headScript()->appendScript($this->jsTranslations()->getScript());
+        if($loggedin = $this->auth()->isLoggedIn()) {
+          $user_id = $loggedin->id;
+          $loggedin = true;
+        } else {
+          $user_id = false;
+        }
+        $this->headScript()->appendScript(
+          'var userIsLoggedIn = ' . ($loggedin ? 'true' : 'false') . ';'
+        );
       }
 
       // Session keep-alive