Skip to content

Commit

Permalink
Unset the save_handler for PHP7.2
Browse files Browse the repository at this point in the history
Forward port changes from #11619 and fix #11628
  • Loading branch information
markstory committed Jan 19, 2018
1 parent 77e0538 commit 0f4225d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Network/Session.php
Expand Up @@ -108,12 +108,16 @@ public static function create($sessionConfig = [])
$sessionConfig['ini']['session.name'] = $sessionConfig['cookie'];
}

// In PHP7.1.0+ session.save_handler can't be set to user by the user.
// https://github.com/php/php-src/blob/master/ext/session/session.c#L559
if (!empty($sessionConfig['handler']) && version_compare(PHP_VERSION, '7.1.0', '<=')) {
if (!empty($sessionConfig['handler'])) {
$sessionConfig['ini']['session.save_handler'] = 'user';
}

// In PHP7.2.0+ session.save_handler can't be set to user by the user.
// https://github.com/php/php-src/commit/a93a51c3bf4ea1638ce0adc4a899cb93531b9f0d
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
unset($sessionConfig['ini']['session.save_handler']);
}

if (!isset($sessionConfig['ini']['session.cookie_httponly']) && ini_get('session.cookie_httponly') != 1) {
$sessionConfig['ini']['session.cookie_httponly'] = 1;
}
Expand Down

0 comments on commit 0f4225d

Please sign in to comment.