Skip to content

Commit

Permalink
Fix session var detection
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelAlphonso committed Apr 3, 2019
1 parent 7e1eb80 commit 9da61b1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Charcoal/Cache/Middleware/CacheMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ public function __invoke(RequestInterface $request, ResponseInterface $response,
return $next($request, $response);
}

if (!$this->isSkipCache($request)) {
if ($this->isSkipCache($request)) {
return $next($request, $response);
}

$cacheKey = $this->cacheKeyFromRequest($request);
$cacheItem = $this->cachePool->getItem($cacheKey);

Expand Down Expand Up @@ -290,7 +290,16 @@ private function isSkipCache(RequestInterface $request)
foreach ($this->skipCache as $ident => $skip) {
switch ($ident) {
case 'session_vars':
if (session_id() && in_array($_SESSION, $skip)) {
if (empty($skip)) {
continue;
}

if (!session_id()) {
session_cache_limiter(false);
session_start();
}

if (array_intersect_key($_SESSION, array_flip($skip))) {
return true;
}
break;
Expand Down

0 comments on commit 9da61b1

Please sign in to comment.