diff --git a/templates/header.php b/templates/header.php
index 64d1c3cd6f6e12d1fbd29b7d6334ce0ea7f86962..b4ced53f1599ffc0fc10484a36a349c740c63fea 100644
--- a/templates/header.php
+++ b/templates/header.php
@@ -123,10 +123,10 @@ if ($navigation) {
                           && Navigation::getItem('/profile')->isActive();
                 ?>
 
-                
+
 
                 <? if (is_object($GLOBALS['perm']) && PersonalNotifications::isActivated() && $GLOBALS['perm']->have_perm('autor')) : ?>
-                
+
                     <? $notifications = PersonalNotifications::getMyNotifications() ?>
                     <? $lastvisit = (int)UserConfig::get($GLOBALS['user']->id)->getValue('NOTIFICATIONS_SEEN_LAST_DATE') ?>
                     <? foreach ($notifications as $notification) {
@@ -137,7 +137,7 @@ if ($navigation) {
                 <!-- User-Avatar -->
                 <li class="header_avatar_container <?= !empty($alert) ? 'alert' : '' ?> <? if ($active) echo 'active'; ?>" id="avatar-menu-container">
                     <div id="notification-container"  <?= count($notifications) > 0 ? ' class="hoverable"' : '' ?>>
-                        
+
                         <button id="notification_marker" data-toggles="#notification_checkbox" <?= !empty($alert) ? ' class="alert"' : "" ?>
                                 title="<?= sprintf(
                                     ngettext('%u Benachrichtigung', '%u Benachrichtigungen', count($notifications)),
@@ -212,7 +212,7 @@ if ($navigation) {
             <? else: ?>
                 <li>
                     <form method="post" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>">
-                        <?= CSRFProtection::tokenTag() ?>
+                        <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?>
                         <input type="hidden" name="user_config_submitted" value="1">
                         <div id="contrast">
                             <? if (!empty($_SESSION['contrast'])): ?>
@@ -222,7 +222,7 @@ if ($navigation) {
                             <? else: ?>
                                 <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asImg(24) ?>
                                 <button class="as-link" name="set_contrast"><?= _('Hohen Kontrast aktivieren') ?></button>
-                                <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen. 
+                                <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen.
                                 Sie können sie in Ihren persönlichen Einstellungen ändern.'), false, false, true); ?>
                             <? endif ?>
                         </div>
diff --git a/templates/login/_header_languages.php b/templates/login/_header_languages.php
index def8d322e901d08d1522cd17d0145da31928cb3b..db8f41a82dee3034edd970d22a57d5243f5cca62 100644
--- a/templates/login/_header_languages.php
+++ b/templates/login/_header_languages.php
@@ -1,5 +1,5 @@
 <form id="language-selector" method="POST" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>">
-    <?= CSRFProtection::tokenTag() ?>
+    <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?>
     <input type="hidden" name="user_config_submitted" value="1">
     <select id="languages" name="set_language" class="select2" onchange="this.form.submit()">
         <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $temp_language_key => $temp_language): ?>
@@ -32,4 +32,4 @@
             templateSelection: format
         });
     });
-</script>
\ No newline at end of file
+</script>