Fix undefined array key warning for $_SESSION['user_id'] in index.php

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/a301a563-c83f-44f7-affb-422b2efccfe1

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-01 18:23:16 +00:00 committed by GitHub
parent f9f888ef41
commit e87eefaebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,8 +68,10 @@ if (!$db instanceof OGPDatabase) {
}
// Logged in user settings - access this global variable where needed
if(hasValue($_SESSION['user_id'])){
$loggedInUserInfo = $db->getUserById($_SESSION['user_id']);
// Guard: read user_id only if it exists in the session to avoid undefined-key warnings.
$sessionUserId = $_SESSION['user_id'] ?? null;
if(hasValue($sessionUserId)){
$loggedInUserInfo = $db->getUserById($sessionUserId);
}
$settings = $db->getSettings();