Fixed session_start(): Setting option 'session.name' failed [#2408]

This commit is contained in:
Matias Griese
2019-03-19 13:47:35 +02:00
parent 5995515419
commit 982b12a239
2 changed files with 10 additions and 7 deletions

View File

@@ -31,6 +31,7 @@
* Grav 1.6: Fixed settion caching in `FlexIndex`
* Fixed some potential issues/bugs found by phpstan
* Fixed regression in GPM packages casted to Array (ref, getgrav/grav-plugin-admin@e3fc4ce)
* Fixed session_start(): Setting option 'session.name' failed [#2408](https://github.com/getgrav/grav/issues/2408)
# v1.6.0-rc.3
## 02/18/2019

View File

@@ -61,13 +61,13 @@ class Session implements SessionInterface
}
// Set default options.
$options += array(
$options += [
'cache_limiter' => 'nocache',
'use_trans_sid' => 0,
'use_cookies' => 1,
'lazy_write' => 1,
'use_strict_mode' => 1
);
];
$this->setOptions($options);
@@ -160,11 +160,11 @@ class Session implements SessionInterface
foreach ($value as $key2 => $value2) {
$ckey = "{$key}.{$key2}";
if (isset($value2, $allowedOptions[$ckey])) {
$this->ini_set("session.{$ckey}", $value2);
$this->setOption($ckey, $value2);
}
}
} elseif (isset($value, $allowedOptions[$key])) {
$this->ini_set("session.{$key}", $value);
$this->setOption($key, $value);
}
}
}
@@ -195,7 +195,9 @@ class Session implements SessionInterface
$error = $last ? $last['message'] : 'Unknown error';
throw new SessionException('Failed to start session: ' . $error, 500);
} elseif ($user && !$user->isValid()) {
}
if ($user && !$user->isValid()) {
$this->clear();
throw new SessionException('User Invalid', 500);
}
@@ -337,7 +339,7 @@ class Session implements SessionInterface
* @param string $key
* @param mixed $value
*/
protected function ini_set($key, $value)
protected function setOption($key, $value)
{
if (!\is_string($value)) {
if (\is_bool($value)) {
@@ -348,6 +350,6 @@ class Session implements SessionInterface
}
$this->options[$key] = $value;
ini_set($key, $value);
ini_set("session.{$key}", $value);
}
}