diff --git a/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php b/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php
index c8b102717d..ffa50971cc 100644
--- a/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php
@@ -3,13 +3,14 @@
 namespace Drupal\Core\Cache\Context;
 
 use Drupal\Component\Utility\Crypt;
+use Drupal\Core\Cache\CacheableMetadata;
 
 /**
  * Defines the SessionCacheContext service, for "per session" caching.
  *
  * Cache context ID: 'session'.
  */
-class SessionCacheContext extends RequestStackCacheContextBase {
+class SessionCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
 
   /**
    * {@inheritdoc}
@@ -22,8 +23,18 @@ public static function getLabel() {
    * {@inheritdoc}
    */
   public function getContext() {
-    $sid = $this->requestStack->getCurrentRequest()->getSession()->getId();
-    return Crypt::hashBase64($sid);
+    if ($this->requestStack->getCurrentRequest()->hasSession()) {
+      $sid = $this->requestStack->getCurrentRequest()->getSession()->getId();
+      return Crypt::hashBase64($sid);
+    }
+    return 'none';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheableMetadata() {
+    return new CacheableMetadata();
   }
 
 }
