- setSession('admin_login', '');
- setSession('admin_md5' , '');
- setSession('admin_last' , '');
- setSession('admin_to' , '');
-
- // Destroy session and return status
- if ($destroy) {
- return session_destroy();
+ setAdminId(0);
+ setAdminMd5('');
+ setAdminLast(0);
+
+ // Remove "cache"
+ unset($GLOBALS['isAdmin']);
+
+ // Destroy session if requested and return status
+ if ($destroy === TRUE) {
+ return destroySession();
+ } // END - if
+
+ // All fine if the session shall not really be destroyed
+ return TRUE;
+}
+
+// Destroys session and resets some "caches"
+function destroySession () {
+ // Unset "cache"
+ unset($GLOBALS['isValidSession']);
+
+ // Destroy session
+ return session_destroy();
+}
+
+// Checks whether the session is valid
+function isValidSession () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Then determine it
+ $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['valid_session'])) && ($GLOBALS['valid_session'] === TRUE) && (isset($_COOKIE[session_name()])));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether all given session data is set
+function isSessionDataSet ($sessionData) {
+ // Default is set
+ $isset = TRUE;
+
+ // Check all
+ foreach ($sessionData as $key) {
+ // Is this element set?
+ $isset = (($isset) && (isSessionVariableSet($key)));
+ } // END - foreach
+
+ // Return result
+ return $isset;
+}
+
+// Initializes session
+function initSession () {
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CALLED!');
+
+ // Is ext-sql_patches there and newer?
+ if (isExtensionInstalledAndNewer('sql_patches', '0.5.3')) {
+ // Set session save path if set
+ if ((isConfigEntrySet('session_save_path')) && (getConfig('session_save_path') != '')) {
+ // Please make sure this valid!
+ session_save_path(getConfig('session_save_path'));
+ } // END - if
+ } // END - if
+
+ // Is a session id there?
+ if (!isValidSession()) {
+ // Start the session
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Initializing session ...');
+ $GLOBALS['valid_session'] = session_start();
+ $GLOBALS['isValidSession'] = TRUE;
+
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'session_id=' . session_id());