SessionCacheContext.php in Drupal 10
File
core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Component\Utility\Crypt;
class SessionCacheContext extends RequestStackCacheContextBase {
public static function getLabel() {
return t('Session');
}
public function getContext() {
$request = $this->requestStack
->getCurrentRequest();
if ($request
->hasSession()) {
return Crypt::hashBase64($request
->getSession()
->getId());
}
return 'none';
}
}