From e87eefaebc7bf488f707fc5f0741ebdcc9f26c89 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 May 2026 18:23:16 +0000 Subject: [PATCH] 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> --- index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 69e69721..be4737ed 100644 --- a/index.php +++ b/index.php @@ -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();