class NoSessionOpen
Same name in other branches
- 9 core/lib/Drupal/Core/PageCache/RequestPolicy/NoSessionOpen.php \Drupal\Core\PageCache\RequestPolicy\NoSessionOpen
- 10 core/lib/Drupal/Core/PageCache/RequestPolicy/NoSessionOpen.php \Drupal\Core\PageCache\RequestPolicy\NoSessionOpen
- 11.x core/lib/Drupal/Core/PageCache/RequestPolicy/NoSessionOpen.php \Drupal\Core\PageCache\RequestPolicy\NoSessionOpen
A policy allowing delivery of cached pages when there is no session open.
Do not serve cached pages to authenticated users, or to anonymous users when $_SESSION is non-empty. $_SESSION may contain status messages from a form submission, the contents of a shopping cart, or other user-specific content that should not be cached and displayed to other users.
Hierarchy
- class \Drupal\Core\PageCache\RequestPolicy\NoSessionOpen implements \Drupal\Core\PageCache\RequestPolicyInterface
Expanded class hierarchy of NoSessionOpen
2 files declare their use of NoSessionOpen
- DefaultRequestPolicy.php in core/
lib/ Drupal/ Core/ PageCache/ DefaultRequestPolicy.php - NoSessionOpenTest.php in core/
tests/ Drupal/ Tests/ Core/ PageCache/ NoSessionOpenTest.php
File
-
core/
lib/ Drupal/ Core/ PageCache/ RequestPolicy/ NoSessionOpen.php, line 17
Namespace
Drupal\Core\PageCache\RequestPolicyView source
class NoSessionOpen implements RequestPolicyInterface {
/**
* The session configuration.
*
* @var \Drupal\Core\Session\SessionConfigurationInterface
*/
protected $sessionConfiguration;
/**
* Constructs a new page cache session policy.
*
* @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration
* The session configuration.
*/
public function __construct(SessionConfigurationInterface $session_configuration) {
$this->sessionConfiguration = $session_configuration;
}
/**
* {@inheritdoc}
*/
public function check(Request $request) {
if (!$this->sessionConfiguration
->hasSession($request)) {
return static::ALLOW;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
NoSessionOpen::$sessionConfiguration | protected | property | The session configuration. | |
NoSessionOpen::check | public | function | Determines whether delivery of a cached page should be attempted. | Overrides RequestPolicyInterface::check |
NoSessionOpen::__construct | public | function | Constructs a new page cache session policy. | |
RequestPolicyInterface::ALLOW | constant | Allow delivery of cached pages. | ||
RequestPolicyInterface::DENY | constant | Deny delivery of cached pages. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.