Skip to content

Commit

Permalink
Session: don't call session_set_cookie_params() when values was not c…
Browse files Browse the repository at this point in the history
…hanged [Closes #134][Closes #23]
  • Loading branch information
dg committed Mar 14, 2018
1 parent b852132 commit 3ea16d9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Http/Session.php
Expand Up @@ -373,15 +373,13 @@ public function getOptions(): array
private function configure(array $config): void
{
$special = ['cache_expire' => 1, 'cache_limiter' => 1, 'save_path' => 1, 'name' => 1];
$cookie = $origCookie = session_get_cookie_params();

foreach ($config as $key => $value) {
if ($value === null || ini_get("session.$key") == $value) { // intentionally ==
continue;

} elseif (strncmp($key, 'cookie_', 7) === 0) {
if (!isset($cookie)) {
$cookie = session_get_cookie_params();
}
$cookie[substr($key, 7)] = $value;

} else {
Expand All @@ -401,7 +399,7 @@ private function configure(array $config): void
}
}

if (isset($cookie)) {
if ($cookie !== $origCookie) {
session_set_cookie_params(
$cookie['lifetime'], $cookie['path'], $cookie['domain'],
$cookie['secure'], $cookie['httponly']
Expand Down

0 comments on commit 3ea16d9

Please sign in to comment.