Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

SessionCacheContext.php

Namespace

Drupal\Core\Cache\Context

File

core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php

View source
<?php

namespace Drupal\Core\Cache\Context;

use Drupal\Component\Utility\Crypt;

/**
 * Defines the SessionCacheContext service, for "per session" caching.
 *
 * Cache context ID: 'session'.
 */
class SessionCacheContext extends RequestStackCacheContextBase {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Session');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return Crypt::hashBase64($this->requestStack
            ->getSession()
            ->getId());
    }

}

Classes

Title Deprecated Summary
SessionCacheContext Defines the SessionCacheContext service, for "per session" caching.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal