Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php \Drupal\Core\Cache\Context\SessionCacheContext
  2. 9 core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php \Drupal\Core\Cache\Context\SessionCacheContext

Defines the SessionCacheContext service, for "per session" caching.

Cache context ID: 'session'.

Hierarchy

Expanded class hierarchy of SessionCacheContext

1 file declares its use of SessionCacheContext
SessionCacheContextTest.php in core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php
1 string reference to 'SessionCacheContext'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses SessionCacheContext
cache_context.session in core/core.services.yml
Drupal\Core\Cache\Context\SessionCacheContext

File

core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php, line 12

Namespace

Drupal\Core\Cache\Context
View source
class SessionCacheContext extends RequestStackCacheContextBase {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Session');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return Crypt::hashBase64($this->requestStack
      ->getSession()
      ->getId());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RequestStackCacheContextBase::$requestStack protected property The request stack.
RequestStackCacheContextBase::__construct public function Constructs a new RequestStackCacheContextBase class.
SessionCacheContext::getContext public function
SessionCacheContext::getLabel public static function