Skip to content

Commit 9da61b1

Browse files
committed
Fix session var detection
1 parent 7e1eb80 commit 9da61b1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Charcoal/Cache/Middleware/CacheMiddleware.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public function __invoke(RequestInterface $request, ResponseInterface $response,
183183
return $next($request, $response);
184184
}
185185

186-
if (!$this->isSkipCache($request)) {
186+
if ($this->isSkipCache($request)) {
187187
return $next($request, $response);
188188
}
189-
189+
190190
$cacheKey = $this->cacheKeyFromRequest($request);
191191
$cacheItem = $this->cachePool->getItem($cacheKey);
192192

@@ -290,7 +290,16 @@ private function isSkipCache(RequestInterface $request)
290290
foreach ($this->skipCache as $ident => $skip) {
291291
switch ($ident) {
292292
case 'session_vars':
293-
if (session_id() && in_array($_SESSION, $skip)) {
293+
if (empty($skip)) {
294+
continue;
295+
}
296+
297+
if (!session_id()) {
298+
session_cache_limiter(false);
299+
session_start();
300+
}
301+
302+
if (array_intersect_key($_SESSION, array_flip($skip))) {
294303
return true;
295304
}
296305
break;

0 commit comments

Comments
 (0)