diff --git a/4dev/tests/CoreLibsACLLoginTest.php b/4dev/tests/CoreLibsACLLoginTest.php
index 42c692be..919f2aff 100644
--- a/4dev/tests/CoreLibsACLLoginTest.php
+++ b/4dev/tests/CoreLibsACLLoginTest.php
@@ -15,6 +15,7 @@ final class CoreLibsACLLoginTest extends TestCase
{
private static $db;
private static $log;
+ private static $session;
/**
* start DB conneciton, setup DB, etc
@@ -28,6 +29,8 @@ final class CoreLibsACLLoginTest extends TestCase
'The PgSQL extension is not available.'
);
}
+ // init session
+ self::$session = new \CoreLibs\Create\Session('ACLLoginTest');
// logger is always needed
// define basic connection set valid and one invalid
self::$log = new \CoreLibs\Debug\Logging([
@@ -96,7 +99,7 @@ final class CoreLibsACLLoginTest extends TestCase
'ACL\Login Tests have not yet been implemented'
);
- $login = new \CoreLibs\ACL\Login(self::$db, self::$log);
+ $login = new \CoreLibs\ACL\Login(self::$db, self::$log, self::$session);
}
}
diff --git a/4dev/tests/CoreLibsCreateSessionTest.php b/4dev/tests/CoreLibsCreateSessionTest.php
index 066e470e..be419e82 100644
--- a/4dev/tests/CoreLibsCreateSessionTest.php
+++ b/4dev/tests/CoreLibsCreateSessionTest.php
@@ -37,10 +37,10 @@ final class CoreLibsCreateSessionTest extends TestCase
'sessionNameGlobals',
'/^\w+$/'
],
- 'session constant' => [
- 'sessionNameConstant',
- 'c',
- 'sessionNameConstant',
+ 'session name default' => [
+ '',
+ 'd',
+ '',
'/^\w+$/'
],
];
@@ -64,19 +64,22 @@ final class CoreLibsCreateSessionTest extends TestCase
$expected_n,
$expected_i
): void {
- // NEEDS MOCKING
- /* $session_id = '';
+ /*
+ // MOCK class for dummy call
+ $session = new \CoreLibs\Create\Session();
+ $session_id = '';
+ unset($GLOBALS['SET_SESSION_NAME']);
switch ($type) {
case 'p':
- $session_id = \CoreLibs\Create\Session::startSession($input);
+ $session_id = $session->startSession($input);
break;
case 'g':
$GLOBALS['SET_SESSION_NAME'] = $input;
- $session_id = \CoreLibs\Create\Session::startSession();
+ $session_id = $session->startSession();
break;
- case 'c':
- define('SET_SESSION_NAME', $input);
- $session_id = \CoreLibs\Create\Session::startSession();
+ case 'd':
+ $expected_n = ini_get('session.name');
+ $session_id = \$session->startSession();
break;
}
$this->assertMatchesRegularExpression(
@@ -85,11 +88,11 @@ final class CoreLibsCreateSessionTest extends TestCase
);
$this->assertMatchesRegularExpression(
$expected_i,
- (string)\CoreLibs\Create\Session::getSessionId()
+ (string)$session->getSessionId()
);
$this->assertEquals(
$expected_n,
- \CoreLibs\Create\Session::getSessionName()
+ $session->getSessionName()
);
if ($type == 'g') {
unset($GLOBALS['SET_SESSION_NAME']);
diff --git a/www/admin/class_test.admin.backend.php b/www/admin/class_test.admin.backend.php
index 0af630fd..f3820459 100644
--- a/www/admin/class_test.admin.backend.php
+++ b/www/admin/class_test.admin.backend.php
@@ -23,14 +23,12 @@ define('USE_DATABASE', true);
require 'config.php';
// override ECHO ALL FALSE
$ECHO_ALL = true;
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-admin';
+$SET_SESSION_NAME = EDIT_SESSION_NAME;
ob_end_flush();
+$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
$log = new CoreLibs\Debug\Logging([
'log_folder' => BASE . LOG,
'file_id' => $LOG_FILE_ID,
@@ -49,7 +47,7 @@ $l10n = new \CoreLibs\Language\L10n(
$locale['domain'],
$locale['path'],
);
-$backend = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
+$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
print "";
diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php
index 111c839d..3f058470 100644
--- a/www/admin/class_test.array.php
+++ b/www/admin/class_test.array.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-array';
ob_end_flush();
diff --git a/www/admin/class_test.autoloader.php b/www/admin/class_test.autoloader.php
index 8012a352..24d85cf7 100644
--- a/www/admin/class_test.autoloader.php
+++ b/www/admin/class_test.autoloader.php
@@ -20,10 +20,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-autoloader';
ob_end_flush();
diff --git a/www/admin/class_test.byte.php b/www/admin/class_test.byte.php
index 01b0c6a6..573a91d8 100644
--- a/www/admin/class_test.byte.php
+++ b/www/admin/class_test.byte.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-byte';
ob_end_flush();
diff --git a/www/admin/class_test.colors.php b/www/admin/class_test.colors.php
index 9d8b6bec..a66a0783 100644
--- a/www/admin/class_test.colors.php
+++ b/www/admin/class_test.colors.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-colors';
ob_end_flush();
diff --git a/www/admin/class_test.datetime.php b/www/admin/class_test.datetime.php
index e88af2b3..cf07f2c7 100644
--- a/www/admin/class_test.datetime.php
+++ b/www/admin/class_test.datetime.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-datetime';
ob_end_flush();
diff --git a/www/admin/class_test.email.php b/www/admin/class_test.email.php
index aae7a4d2..9652ffe7 100644
--- a/www/admin/class_test.email.php
+++ b/www/admin/class_test.email.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-email';
ob_end_flush();
diff --git a/www/admin/class_test.encoding.php b/www/admin/class_test.encoding.php
index e7cd6884..5cb34e16 100644
--- a/www/admin/class_test.encoding.php
+++ b/www/admin/class_test.encoding.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-encoding';
ob_end_flush();
diff --git a/www/admin/class_test.file.php b/www/admin/class_test.file.php
index 4ff3af84..4cb0b0a8 100644
--- a/www/admin/class_test.file.php
+++ b/www/admin/class_test.file.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-datetime';
ob_end_flush();
diff --git a/www/admin/class_test.hash.php b/www/admin/class_test.hash.php
index 2bd4dfe0..5e26c130 100644
--- a/www/admin/class_test.hash.php
+++ b/www/admin/class_test.hash.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-hash';
ob_end_flush();
diff --git a/www/admin/class_test.html.php b/www/admin/class_test.html.php
index e15318b5..e009ce23 100644
--- a/www/admin/class_test.html.php
+++ b/www/admin/class_test.html.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-html';
ob_end_flush();
diff --git a/www/admin/class_test.image.php b/www/admin/class_test.image.php
index 903504da..170105c6 100644
--- a/www/admin/class_test.image.php
+++ b/www/admin/class_test.image.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-image';
ob_end_flush();
diff --git a/www/admin/class_test.json.php b/www/admin/class_test.json.php
index 279fc8f9..10cb559a 100644
--- a/www/admin/class_test.json.php
+++ b/www/admin/class_test.json.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-json';
ob_end_flush();
diff --git a/www/admin/class_test.lang.php b/www/admin/class_test.lang.php
index a84ee41f..3381d76b 100644
--- a/www/admin/class_test.lang.php
+++ b/www/admin/class_test.lang.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-lang';
ob_end_flush();
diff --git a/www/admin/class_test.login.php b/www/admin/class_test.login.php
index ea71f836..9dae22ac 100644
--- a/www/admin/class_test.login.php
+++ b/www/admin/class_test.login.php
@@ -21,13 +21,11 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-login';
+$SET_SESSION_NAME = EDIT_SESSION_NAME;
// init login & backend class
+$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
$log = new CoreLibs\Debug\Logging([
'log_folder' => BASE . LOG,
'file_id' => $LOG_FILE_ID,
@@ -39,7 +37,7 @@ $log = new CoreLibs\Debug\Logging([
'print_all' => $PRINT_ALL ?? false,
]);
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
-$login = new CoreLibs\ACL\Login($db, $log);
+$login = new CoreLibs\ACL\Login($db, $log, $session);
ob_end_flush();
$PAGE_NAME = 'TEST CLASS: LOGIN';
diff --git a/www/admin/class_test.math.php b/www/admin/class_test.math.php
index 2ac6cd61..b84c504c 100644
--- a/www/admin/class_test.math.php
+++ b/www/admin/class_test.math.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-math';
ob_end_flush();
diff --git a/www/admin/class_test.mime.php b/www/admin/class_test.mime.php
index 3c237e24..4bd2598d 100644
--- a/www/admin/class_test.mime.php
+++ b/www/admin/class_test.mime.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-mime';
ob_end_flush();
diff --git a/www/admin/class_test.output.form.php b/www/admin/class_test.output.form.php
index 64d657f7..27f314d6 100644
--- a/www/admin/class_test.output.form.php
+++ b/www/admin/class_test.output.form.php
@@ -23,10 +23,6 @@ define('USE_DATABASE', true);
require 'config.php';
// override ECHO ALL FALSE
$ECHO_ALL = true;
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-form';
ob_end_flush();
diff --git a/www/admin/class_test.password.php b/www/admin/class_test.password.php
index af8a81f1..891a9838 100644
--- a/www/admin/class_test.password.php
+++ b/www/admin/class_test.password.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-pass';
ob_end_flush();
diff --git a/www/admin/class_test.php b/www/admin/class_test.php
index c3c7687e..37be6278 100644
--- a/www/admin/class_test.php
+++ b/www/admin/class_test.php
@@ -21,14 +21,12 @@ ob_start();
define('USE_DATABASE', true);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest';
+$SET_SESSION_NAME = EDIT_SESSION_NAME;
// init login & backend class
+$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
$log = new CoreLibs\Debug\Logging([
'log_folder' => BASE . LOG,
'file_id' => $LOG_FILE_ID,
@@ -40,14 +38,14 @@ $log = new CoreLibs\Debug\Logging([
'print_all' => $PRINT_ALL ?? false,
]);
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
-$login = new CoreLibs\ACL\Login($db, $log);
+$login = new CoreLibs\ACL\Login($db, $log, $session);
$locale = \CoreLibs\Language\GetLocale::setLocale();
$l10n = new \CoreLibs\Language\L10n(
$locale['locale'],
$locale['domain'],
$locale['path'],
);
-$backend = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
+$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
$backend->db->dbInfo(true);
ob_end_flush();
diff --git a/www/admin/class_test.phpv.php b/www/admin/class_test.phpv.php
index dba43dd1..79027cdd 100644
--- a/www/admin/class_test.phpv.php
+++ b/www/admin/class_test.phpv.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-phpv';
ob_end_flush();
diff --git a/www/admin/class_test.randomkey.php b/www/admin/class_test.randomkey.php
index 3e82e0f8..ceec4542 100644
--- a/www/admin/class_test.randomkey.php
+++ b/www/admin/class_test.randomkey.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-randomkey';
ob_end_flush();
diff --git a/www/admin/class_test.readenvfile.php b/www/admin/class_test.readenvfile.php
index 7cdc7e37..ee5b277e 100644
--- a/www/admin/class_test.readenvfile.php
+++ b/www/admin/class_test.readenvfile.php
@@ -14,10 +14,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-readEnvFile';
ob_end_flush();
diff --git a/www/admin/class_test.runningtime.php b/www/admin/class_test.runningtime.php
index 6a086a0a..7d33d272 100644
--- a/www/admin/class_test.runningtime.php
+++ b/www/admin/class_test.runningtime.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-runningtime';
ob_end_flush();
diff --git a/www/admin/class_test.session.php b/www/admin/class_test.session.php
index 6c1256aa..b65dc10c 100644
--- a/www/admin/class_test.session.php
+++ b/www/admin/class_test.session.php
@@ -43,10 +43,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-// if (!defined('SET_SESSION_NAME')) {
-// define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-// }
// define log file id
$LOG_FILE_ID = 'classTest-session';
ob_end_flush();
@@ -62,6 +58,7 @@ $log = new CoreLibs\Debug\Logging([
'print_all' => $PRINT_ALL ?? false,
]);
use CoreLibs\Create\Session;
+$session = new Session();
$PAGE_NAME = 'TEST CLASS: SESSION';
print "";
@@ -76,15 +73,15 @@ $value = 'bar';
foreach (['123', '123-123', '123abc'] as $_session_name) {
print "[UNSET] Session Name valid for " . $_session_name . ": "
- . (Session::checkValidSessionName($_session_name) ? 'Valid' : 'Invalid') . "
";
+ . ($session->checkValidSessionName($_session_name) ? 'Valid' : 'Invalid') . "
";
}
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "
";
-print "[UNSET] Current session id: " . Session::getSessionId() . "
";
-print "[UNSET] Current session name: " . Session::getSessionName() . "
";
-print "[UNSET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "
";
-print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "
";
+print "[UNSET] Current session id: " . $session->getSessionId() . "
";
+print "[UNSET] Current session name: " . $session->getSessionName() . "
";
+print "[UNSET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "
";
+print "[UNSET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "
";
if (isset($_SESSION)) {
print "[UNSET] _SESSION is: set
";
} else {
@@ -92,22 +89,22 @@ if (isset($_SESSION)) {
}
#
print "[UNSET] To set session name valid: "
- . (Session::checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "
";
-if (false === ($session = Session::startSession($session_name))) {
- print "[FAILED] Session start failed: " . Session::getErrorStr() . "
";
+ . ($session->checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "[FAILED] Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "[SET] Current session id: " . $session . "
";
+ print "[SET] Current session id: " . $session_id . "
";
}
// set again
-if (false === ($session = Session::startSession($session_name))) {
- print "[2 FAILED] Session start failed: " . Session::getErrorStr() . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "[2 FAILED] Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "[2 SET] Current session id: " . $session . "
";
+ print "[2 SET] Current session id: " . $session_id . "
";
}
-print "[SET] Current session id: " . Session::getSessionId() . "
";
-print "[SET] Current session name: " . Session::getSessionName() . "
";
-print "[SET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "
";
-print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "
";
+print "[SET] Current session id: " . $session->getSessionId() . "
";
+print "[SET] Current session name: " . $session->getSessionName() . "
";
+print "[SET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "
";
+print "[SET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "
";
if (isset($_SESSION)) {
print "[SET] _SESSION is: set
";
} else {
@@ -117,51 +114,51 @@ if (!isset($_SESSION['counter'])) {
$_SESSION['counter'] = 0;
}
$_SESSION['counter']++;
-print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
+print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
$_SESSION[$var] = $value;
-print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
+print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
print "[READ] Confirm " . $var . " is " . $value . ": "
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "
";
// differnt session name
$session_name = 'class-test-session-ALT';
-if (false === ($session = Session::startSession($session_name))) {
- print "[3 FAILED] Session start failed: " . Session::getErrorStr() . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "[3 FAILED] Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "[3 SET] Current session id: " . $session . "
";
+ print "[3 SET] Current session id: " . $session_id . "
";
}
-print "[SET AGAIN] Current session id: " . Session::getSessionId() . "
";
+print "[SET AGAIN] Current session id: " . $session->getSessionId() . "
";
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "
";
// close session
-Session::writeClose();
+$session->writeClose();
// will never be written
$_SESSION['will_never_be_written'] = 'empty';
// open again
$session_name = 'class-test-session';
-if (false === ($session = Session::startSession($session_name))) {
- print "[4 FAILED] Session start failed: " . Session::getErrorStr() . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "[4 FAILED] Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "[4 SET] Current session id: " . $session . "
";
+ print "[4 SET] Current session id: " . $session_id . "
";
}
-print "[START AGAIN] Current session id: " . Session::getSessionId() . "
";
+print "[START AGAIN] Current session id: " . $session->getSessionId() . "
";
$_SESSION['will_be_written_again'] = 'Full';
// close session
-Session::writeClose();
+$session->writeClose();
// invalid
$session_name = '123';
-if (false === ($session = Session::startSession($session_name))) {
- print "[5 FAILED] Session start failed: " . Session::getErrorStr() . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "[5 FAILED] Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "[5 SET] Current session id: " . $session . "
";
+ print "[5 SET] Current session id: " . $session_id . "
";
}
-print "[BAD NAME] Current session id: " . Session::getSessionId() . "
";
-print "[BAD NAME] Current session name: " . Session::getSessionName() . "
";
-print "[BAD NAME] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "
";
-print "[BAD NAME] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "
";
+print "[BAD NAME] Current session id: " . $session->getSessionId() . "
";
+print "[BAD NAME] Current session name: " . $session->getSessionName() . "
";
+print "[BAD NAME] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "
";
+print "[BAD NAME] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "
";
// error message
print $log->printErrorMsg();
diff --git a/www/admin/class_test.session.read.php b/www/admin/class_test.session.read.php
index 6a63b066..7af08e61 100644
--- a/www/admin/class_test.session.read.php
+++ b/www/admin/class_test.session.read.php
@@ -43,10 +43,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-session.read';
ob_end_flush();
@@ -62,6 +58,7 @@ $log = new CoreLibs\Debug\Logging([
'print_all' => $PRINT_ALL ?? false,
]);
use CoreLibs\Create\Session;
+$session = new Session();
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
print "";
@@ -77,28 +74,28 @@ $value = 'bar';
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "
";
-print "[UNSET] Current session id: " . Session::getSessionId() . "
";
-print "[UNSET] Current session name: " . Session::getSessionName() . "
";
-print "[UNSET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "
";
-print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "
";
+print "[UNSET] Current session id: " . $session->getSessionId() . "
";
+print "[UNSET] Current session name: " . $session->getSessionName() . "
";
+print "[UNSET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "
";
+print "[UNSET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "
";
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
// start
-if (false === ($session = Session::startSession($session_name))) {
- print "Session start failed: " . Session::getErrorStr() . "
";
+if (false === ($session_id = $session->startSession($session_name))) {
+ print "Session start failed: " . $session->getErrorStr() . "
";
} else {
- print "Current session id: " . $session . "
";
+ print "Current session id: " . $session_id . "
";
}
// set again
-if (false === ($session = Session::startSession($session_name))) {
+if (false === ($session_id = $session->startSession($session_name))) {
print "[2] Session start failed
";
} else {
- print "[2] Current session id: " . $session . "
";
+ print "[2] Current session id: " . $session_id . "
";
}
-print "[SET] Current session id: " . Session::getSessionId() . "
";
-print "[SET] Current session name: " . Session::getSessionName() . "
";
-print "[SET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "
";
-print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "
";
+print "[SET] Current session id: " . $session->getSessionId() . "
";
+print "[SET] Current session name: " . $session->getSessionName() . "
";
+print "[SET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "
";
+print "[SET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "
";
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "
";
print "[READ] Confirm " . $var . " is " . $value . ": "
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "
";
diff --git a/www/admin/class_test.smarty.php b/www/admin/class_test.smarty.php
index f1c0c1ed..6a115d5b 100644
--- a/www/admin/class_test.smarty.php
+++ b/www/admin/class_test.smarty.php
@@ -23,10 +23,6 @@ define('USE_DATABASE', true);
require 'config.php';
// override ECHO ALL FALSE
$ECHO_ALL = true;
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-smarty';
ob_end_flush();
diff --git a/www/admin/class_test.system.php b/www/admin/class_test.system.php
index 8bc13190..c36687dc 100644
--- a/www/admin/class_test.system.php
+++ b/www/admin/class_test.system.php
@@ -21,10 +21,6 @@ ob_start();
define('USE_DATABASE', false);
// sample config
require 'config.php';
-// set session name
-if (!defined('SET_SESSION_NAME')) {
- define('SET_SESSION_NAME', EDIT_SESSION_NAME);
-}
// define log file id
$LOG_FILE_ID = 'classTest-system';
ob_end_flush();
@@ -50,16 +46,23 @@ print "