Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 509b5b8

Browse files
authored
PHP v7.0 fallback added re session_create_id
1 parent 51cf24b commit 509b5b8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/settings-common.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,24 @@
2525
ini_set('session.httponly', true); // Only allow http protocol (ie, not JS) access to the cookie
2626
ini_set('session.cookie_httponly', true); // Only allow cookie via http protocol (ie, not JS) access to the cookie
2727
// ini_set('session.save_path', dirname(__FILE__) . '/../tmp'); // Localise the session files to /tmp
28-
if(false === isset($_COOKIE['ICEcoder'])) {
29-
$_COOKIE['ICEcoder'] = session_create_id();
30-
}
31-
session_id($_COOKIE['ICEcoder']);
3228

29+
if (false === isset($_COOKIE['ICEcoder'])) {
30+
// PHP v7.1+
31+
if (function_exists('session_create_id')) {
32+
$_COOKIE['ICEcoder'] = session_create_id();
33+
session_id($_COOKIE['ICEcoder']);
34+
// PHP v7.0 fallback
35+
} else {
36+
session_start();
37+
$_COOKIE['ICEcoder'] = session_id();
38+
}
39+
}
3340
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
3441
ini_set('session.cookie_secure', '1'); // Only allows access to session ID when protocol is HTTPS, switched on under 'if https' condition
3542
}
36-
session_start(); // Finally, start the session!
43+
if (false === isset($_SESSION)) {
44+
session_start();
45+
}
3746
if (false === isset($_SESSION['csrf'])){
3847
session_regenerate_id(true); // Create a new ID to help prevent fixation & hijacking
3948
$_COOKIE['ICEcoder'] = session_id();

0 commit comments

Comments
 (0)