3 namespace Drupal\Core\PageCache\RequestPolicy;
5 use Drupal\Core\PageCache\RequestPolicyInterface;
6 use Drupal\Core\Session\SessionConfigurationInterface;
7 use Symfony\Component\HttpFoundation\Request;
10 * A policy allowing delivery of cached pages when there is no session open.
12 * Do not serve cached pages to authenticated users, or to anonymous users when
13 * $_SESSION is non-empty. $_SESSION may contain status messages from a form
14 * submission, the contents of a shopping cart, or other userspecific content
15 * that should not be cached and displayed to other users.
17 class NoSessionOpen implements RequestPolicyInterface {
20 * The session configuration.
22 * @var \Drupal\Core\Session\SessionConfigurationInterface
24 protected $sessionConfiguration;
27 * Constructs a new page cache session policy.
29 * @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration
30 * The session configuration.
32 public function __construct(SessionConfigurationInterface $session_configuration) {
33 $this->sessionConfiguration = $session_configuration;
39 public function check(Request $request) {
40 if (!$this->sessionConfiguration->hasSession($request)) {